tag:blogger.com,1999:blog-882821950355432699.post765536260981247988..comments2022-12-07T21:25:53.386+11:00Comments on Paul Batum: Getting to know System.Net.WebSockets: A simple ASP.NET echo serverPaulhttp://www.blogger.com/profile/18224234643439645641noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-882821950355432699.post-91020372944757934502018-02-16T02:26:52.321+11:002018-02-16T02:26:52.321+11:00If yes, how to call it from client?If yes, how to call it from client?Anonymoushttps://www.blogger.com/profile/08897817471408888118noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-31368654656862381662018-02-16T02:26:19.251+11:002018-02-16T02:26:19.251+11:00Hi Paul, Can we call REST API using WebSocket?Hi Paul, Can we call REST API using WebSocket?Anonymoushttps://www.blogger.com/profile/08897817471408888118noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-58403793688617836052014-07-02T12:09:27.941+10:002014-07-02T12:09:27.941+10:00Unfortunately I don't have an example of how t...Unfortunately I don't have an example of how to do that. I know that SignalR does have integrated auth, so you may find its easier to implement your scenario using SignalR.Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-91707277374482686722014-07-02T08:41:08.019+10:002014-07-02T08:41:08.019+10:00hi my site have form authentication how can i chec...hi my site have form authentication how can i check in the handler for form auhtentication???Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-57159692050774503212014-04-08T02:15:25.419+10:002014-04-08T02:15:25.419+10:00I think you might be using an older sample, try th...I think you might be using an older sample, try the ones here: https://github.com/paulbatum/WebSocket-Samples<br />Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-84251149795610242182014-04-07T21:04:36.726+10:002014-04-07T21:04:36.726+10:00Hi Paul,
I have seen your video and downloaded the...Hi Paul,<br />I have seen your video and downloaded the BasicAppNetChat application. I ran the code the way it is instructed in video. But in the chrome, I am getting an error as;<br />error during WebSocket handshake: Unexpected response code: 200<br /><br />Am I missing anything ?VJhttps://www.blogger.com/profile/16978063319215900019noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-60561190898155989912014-01-30T05:55:15.284+11:002014-01-30T05:55:15.284+11:00Hi Vivek,
I'm not familiar with the code proj...Hi Vivek,<br /><br />I'm not familiar with the code project you linked to. If you'd like to get started with websockets I suggest you try out my samples:<br />https://github.com/paulbatum/WebSocket-SamplesPaulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-71278741826284712332014-01-29T19:08:16.788+11:002014-01-29T19:08:16.788+11:00Hello Paul,
I got your email address from your bl...Hello Paul,<br /><br />I got your email address from your blog i am trying to develop webrtc video chat conference in traditional asp.net<br />so i have took help form this link<br /><br />http://www.codeproject.com/Articles/618032/Using-WebSocket-in-NET-4-5-Part-2<br /><br />But it gives me error some random error in my console( do not know what to do with it i already installed websocket in my IIS 8.0.<br /><br />Please help to over come this problem<br /><br />WebSocket connection to 'ws://localhost/DemoRtc/WSHandler.ashx' failed: Error during WebSocket handshake: Unexpected response code: 500 Anonymoushttps://www.blogger.com/profile/17041246815186073967noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-32826656529950684022014-01-21T06:59:40.777+11:002014-01-21T06:59:40.777+11:00Thanks! Most of the examples I've found at IIS...Thanks! Most of the examples I've found at IIS-specific. This link was very helpful!Billnoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-39922051088478059002013-07-24T11:37:22.445+10:002013-07-24T11:37:22.445+10:00Unfortunately, I am not sure how you would bring w...Unfortunately, I am not sure how you would bring websocket server capabilities to WinRT. You wouldn't be able to reuse the .NET 4.5 implementation because it requires either HttpListener or ASP.NET, neither of which are part of WinRT. If you were going to try to hack it together, I think the best way would be to take an open source .NET websocket implementation (there are a few out there), and modify it to use the WinRT socket API. I am not sure how feasible this is but that is what I would try.Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-1839552148870472432013-07-20T17:28:14.141+10:002013-07-20T17:28:14.141+10:00Paul,
Thanks for the post.
System.Net.Websockets ...Paul,<br />Thanks for the post.<br /><br />System.Net.Websockets provides a WebSocket Server funcctionality for a .NET application.<br /><br />However, in a WINRT environment, I didn't see anything that will allow me to create a web sockcte server. In WINRT environment, we just have a Windows.Networking namespace which provides "WebSocket CLient" functionality.<br /><br />DO u know if WINRT has any websocket server capability?<br /><br />If not, how can we use System.Net.WebSockets namespace and implement a websocket server and bring that to a winrt environment (any hack?).<br /><br />ThanksSankarshana.Madhavhttps://www.blogger.com/profile/05926054959066494280noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-27365841317877717872013-06-01T02:10:10.676+10:002013-06-01T02:10:10.676+10:00Yes, you would do this using a HTTP header, which ...Yes, you would do this using a HTTP header, which can be set using:<br />http://msdn.microsoft.com/en-us/library/system.net.websockets.clientwebsocketoptions.setrequestheader.aspxPaulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-10231961587456465832013-05-31T19:53:05.672+10:002013-05-31T19:53:05.672+10:00Thanks Paul,
I want to know in System.Net.WebSock...Thanks Paul,<br /><br />I want to know in System.Net.WebSockets(.net 4.5) whether websocket client supports passing authentication header during handshaking.<br /><br />regards,<br />shivaAnonymoushttps://www.blogger.com/profile/08661218030816902671noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-1714859468376828422013-03-22T11:12:31.226+11:002013-03-22T11:12:31.226+11:00Yes, WebSocket connectivity on port 80 isn't p...Yes, WebSocket connectivity on port 80 isn't particularly good. In practice I would recommend that you run the WebSocket traffic over SSL (and use default port of 443) because it makes a huge improvement to the connectivity success rate - the connection just looks like a standard SSL connection, and the intermediary can't tell that you're running WebSockets over it.Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-63425319027282387372013-03-21T08:33:21.853+11:002013-03-21T08:33:21.853+11:00Thanks Paul!
I agree it may work if I try a worke...Thanks Paul!<br /><br />I agree it may work if I try a worker role one more time. However: it appears that websockets on port 80 get blocked quite often for a number of reasons beyond my control, like firewalls (https://github.com/LearnBoost/socket.io/wiki/Socket.IO-and-firewall-software) so I will stick with port 843 which seems to work just fine.Sebastian Burckhardthttp://www.research.microsoft.com/people/sburckhanoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-56207898391273489492013-03-21T05:38:25.458+11:002013-03-21T05:38:25.458+11:00I think the reason your above approach did not wor...I think the reason your above approach did not work on port 80 is that IIS has got control over port 80 (you picked web role). In this configuration, you could use the ASP.NET support for WebSockets instead of http listener (see my other sample) and that would work on port 80 (you will have to enable the WebSocket module in your IIS configuration).<br /><br />Given that you want to use http listener, worker role would be best. Assuming you have the os family set correctly, you have an input endpoint setup in your role config, and you are using an up to date websocket client, I am struggling to think what else could be missing.Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-72217675556116526772013-03-21T04:15:43.126+11:002013-03-21T04:15:43.126+11:00Yes. I now got this to work, after a bit more tink...Yes. I now got this to work, after a bit more tinkering:<br /><br />- using a web role instead of a worker role. I used a WCF web role template, ignored the service it specifies, and just start my own http listener, exactly as in your sample<br />- adding "" to ServiceDefinition.csdef<br />- not using port 80... for some reason, the problem described above (websocket requests are not recognized as such, but appear like normal http requests) still happens when I use port 80. <br /><br />So it's not perfect yet since I would like to use port 80 but at least it runs.Sebastian Burckhardthttp://www.research.microsoft.com/people/sburckhanoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-80784498719684669642013-03-19T12:23:23.692+11:002013-03-19T12:23:23.692+11:00Hi Sebastian,
Have you made sure that your .cscfg...Hi Sebastian,<br /><br />Have you made sure that your .cscfg is specifying osFamily="3" ? This is necessary to ensure that Windows Server 2012 is used. <br /><br />PaulPaulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-86999684353202805822013-03-19T08:48:21.049+11:002013-03-19T08:48:21.049+11:00I have been trying for a while to get a C# websock...I have been trying for a while to get a C# websocket server running in Azure... as far as I understand this should now be possible (because Azure provides Windows Server 2012). However, I have a hard time getting it to work. Are there any samples for this scenario?<br /><br />I am using a worker role that runs the server coder from your sample, and it seems to start o.k. in Azure. Unfortunately, when I connect from a client, it appears that the request is not recognized as a websocket request (the listenerContext.Request.IsWebSocketRequest returns false). Am I missing some configuration?<br /><br />Sebastian Burckhardthttp://www.research.microsoft.com/people/sburckhanoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-87987355279415593912013-03-04T13:02:44.131+11:002013-03-04T13:02:44.131+11:00The WebSocket protocol is designed around a HTTP u...The WebSocket protocol is designed around a HTTP upgrade mechanism, so it makes sense for it to be implemented on top of a webserver. If you take a look at a standalone WebSocket server (such as Fleck - https://github.com/statianzo/Fleck), it will still have some code to do the HTTP based handshake for establishing a WebSocket connection, but it won't serve normal HTTP requests. This is as close as you can get.Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-40892465311539715782013-03-02T04:42:27.303+11:002013-03-02T04:42:27.303+11:00It is possible to create a websocket server withou...It is possible to create a websocket server without having to use some http listener (either IIS on asp.net or HttpListener outside iis)? So, simply connecting to the ws:// instead of upgrading an http connection.<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-17443719715816680562012-09-27T10:53:20.134+10:002012-09-27T10:53:20.134+10:00Hi Tamer,
It really depends on your scenario. If ...Hi Tamer,<br /><br />It really depends on your scenario. If you are talking about LOB desktop applications it might be simpler to just use WCF. If you're talking about web applications then I would look at SignalR.<br /><br />PaulPaulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-31820574948678075792012-09-27T04:44:41.666+10:002012-09-27T04:44:41.666+10:00Paul
I have lots of machine that are running .net ...Paul<br />I have lots of machine that are running .net 4.0 and won't upgrade for some time, question: what libraries do you recommend for windows sockets client / server? <br />thanks.Tamerhttps://www.blogger.com/profile/12322627025878921180noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-14644553933258945222012-08-28T09:12:26.725+10:002012-08-28T09:12:26.725+10:00Hi Coco,
To answer your second post, yes I would ...Hi Coco,<br /><br />To answer your second post, yes I would start with SignalR (on both client and server). This page here has some information about selfhosting SignalR and this would be applicable to running in a Windows Service:<br />https://github.com/SignalR/SignalR/wiki/Self-host<br /><br />The SignalR room on Jabbr is a great way to connect with other SignalR users. You should try that here:<br />http://jabbr.net/#/rooms/signalr<br />Paulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.comtag:blogger.com,1999:blog-882821950355432699.post-59371363982872269532012-08-28T09:07:45.745+10:002012-08-28T09:07:45.745+10:00Hi Coco,
It sounds like SignalR or socket.io woul...Hi Coco,<br /><br />It sounds like SignalR or socket.io would be a good choice for your scenario. The important thing to note is that SignalR and socket.io are not just client side technologies - they both have client and server side components. SignalR has a .NET based server component while socket.io runs on node.js.<br /><br />If you are comfortable developing for .NET, I suggest you look at SignalR. If you would prefer to work with JavaScript as your server side programming language then you should look at using socket.io. There are other options too, but I think these are worthwhile starting points.<br /><br />Scott Hanselman has a good introductory post on SignalR here:<br />http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspxPaulhttps://www.blogger.com/profile/18224234643439645641noreply@blogger.com