My website uses ASP.NET 5 with RC1-Update1 and some communication with the client goes through web sockets (SignalR is used).
During testing I found out that while running on IIS (or IIS Express), communication doesn't work through sockets. SignalR fallbacks to long polling.
SignalR log:
SignalR: Client subscribed to hub 'chathub'.
SignalR: Negotiating with '/signalr/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D'.
SignalR: serverSentEvents transport starting.
SignalR: Attempting to connect to SSE endpoint 'http://localhost:31650/signalr/signalr/connect?transport=serverSentEvents&c…wVlnXCY8bI7R8E&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&tid=2'.
SignalR: serverSentEvents transport timed out when trying to connect.
SignalR: EventSource calling close().
SignalR: serverSentEvents transport failed to connect. Attempting to fall back.
SignalR: foreverFrame transport starting.
SignalR: Forever Frame is not supported by SignalR on browsers with SSE support.
SignalR: foreverFrame transport failed to connect. Attempting to fall back.
SignalR: longPolling transport starting.
SignalR: Opening long polling request to 'http://localhost:31650/signalr/signalr/connect?transport=longPolling&client…8WRrhWwVlnXCY8bI7R8E&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D'.
SignalR: Long poll complete
After long hours of debugging, I started my website directly through dnx (no IIS or anything else) via command line using:
dnx web
And web sockets worked out of the box without any problems.
During my research towards the solution I found out that in nodejs with socket.io web apps, web sockets in IIS must be disabled so that they are correctly forwarded to nodejs (link to resource here on iis.net), so I tried the same thing and got the error (occurs as soon as webSocket
element is present in web.config):
An error occurred attempting to determine the process id of the DNX process hosting your application.
My web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="true" startupTimeLimit="3600" />
<staticContent>
<!-- A bunch of mime types (no difference if removed) -->
</staticContent>
<webSocket enabled="false" />
</system.webServer>
</configuration>
At this point I ran out of ideas. I made sure I have WebSockets installed in windows features and tried deploying my website on Azure (with web sockets turned on) where it will be hosted when finished.
I'd say that the problem is web sockets not being forwarded to DNX, but cannot find the solution for it. Any help would be greatly appreciated.
The problem was in missing package Microsoft.AspNet.WebSockets.Server
and call in startup.cs
app.UseWebSockets()
.
The issues was resolved on GitHub, big thanks to @davidfowl.