1

My server is running Windows Server 2012.

At my client: Is WebSockets the default communication used in the .NET client?

How can I verify which communication method is used by my .NET client?

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71

1 Answers1

3

From the docs:

You can find the transport method used for the connection in the query string data, along with some other values used internally by SignalR:

string transportMethod = queryString["transport"];

And:

The Microsoft.AspNet.SignalR.Client.Transports namespace includes the following classes that you can use to specify the transport.

  • LongPollingTransport
  • ServerSentEventsTransport
  • WebSocketTransport (Available only when both server and client use .NET 4.5.)
  • AutoTransport (Automatically chooses the best transport that is supported by both the client and the server. This is the default transport. Passing this in to the Start method has the same effect as not passing in anything.)

So yeah, the .NET client does support WebSockets if you're using .NET 4.5

sroes
  • 14,663
  • 1
  • 53
  • 72
  • What if my .Net client is on Windows7? how Can I on the client side know which transport is used? – Shachaf.Gortler Apr 30 '14 at 07:53
  • The version of Windows does not matter, the installed .NET version does. I don't think Windows 7 has .NET 4.5 installed by default, so you'd have to do this yourself: http://msdn.microsoft.com/en-us/library/5a4x27ek(v=vs.110).aspx – sroes Apr 30 '14 at 07:59
  • I think you are mistaken WebSockets are not supported on Windows7, please have a look at http://stackoverflow.com/questions/11039438/using-websocket-on-windows7 – Shachaf.Gortler Apr 30 '14 at 08:02
  • They are saying WebSockets are not supported **natively** in Windows 7. The documentation of SignalR clearly states WebSocketTransport is available when the client and server are both using NET 4.5, so SignalR probably doesn't use Windows' native HTTP Server API. Did you already have a look at the `transport` querystring parameter? – sroes Apr 30 '14 at 08:09
  • Yes I checked the queryString["transport"] , both my client and server are .Net 4.5.1 on Windows7 and the transport method is serverSentEvents – Shachaf.Gortler Apr 30 '14 at 08:15
  • Then I think SignalR prefers `ServerSentEventsTransport` over `WebSocketTransport` in your case. Did you try to manually set the `WebSocketTransport`? – sroes Apr 30 '14 at 08:21
  • Yes I set it to web sockets , WebSockets is not supported on win7. http://stackoverflow.com/questions/9119900/websockets-tutorial-on-asp-net/9135334#9135334 – Shachaf.Gortler Apr 30 '14 at 08:33
  • That's weird. I personally wouldn't pay too much attention to the transport being used; I'd trust on SignalR to automatically pick the best one available (when using the AutoTransport). If you really want to force using WebSockets, you maybe have to share some of your code, since the documentation states it should work when you're using .NET 4.5. – sroes Apr 30 '14 at 08:40