Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

websockets timeout with signalr #58

Open
ronnieoverby opened this issue Feb 26, 2016 · 7 comments
Open

websockets timeout with signalr #58

ronnieoverby opened this issue Feb 26, 2016 · 7 comments

Comments

@ronnieoverby
Copy link

When switching my app from Microsoft.Owin.Host.HttpListener to Nowin my signalr hub connections via websockets timeout and then succeed when switching to SSE.

Any idea why this is happening?

Everything else seems to work great with the switch to Nowin.

Here's the js client log showing the timeout:

[11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D'.
jquery.signalR.js:81 [11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Connecting to websocket endpoint 'ws://localhost:64423/signalr/connect?transport=webSockets&clientProtocol=1.4&connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAA3sJBIyVT%2F0m1h7OYIkqKfgAAAAACAAAAAAADZgAAwAAAABAAAAAdukww50k5%2FeCpx8dHi9pUAAAAAASAAACgAAAAEAAAAI5n9S92vwXqZCl5mr9aOaAwAAAA8%2Fo8SguGi4gUcwOYkGmUJj9T4RhUwQ1%2FGBP4fkW2QF%2FX3C44ZRjBStRxwEX2vX%2BQFAAAAGeplDn%2FBZDlgPoSMU5khj2yuSrc&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D&tid=9'.
jquery.signalR.js:81 [11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Websocket opened.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: webSockets timed out when trying to connect.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Closing the Websocket.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Attempting to connect to SSE endpoint 'http://localhost:64423/signalr/connect?transport=serverSentEvents&clientPro…PoSMU5khj2yuSrc&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D&tid=3'.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: EventSource connected.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: serverSentEvents transport selected. Initiating start request.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Invoking eclhub.getEcls
@Bobris
Copy link
Owner

Bobris commented Feb 27, 2016

Actually it does not work for SignalR version I have in repository too ... it throws:

---> (Inner Exception #0) System.NotImplementedException: Metoda nebo operace není implementována.
v Microsoft.AspNet.SignalR.Owin.OwinWebSocketHandler.OwinWebSocket.get_State()
v Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.SendAsync(ArraySegment1 message, WebSocketMessageType messageType, Boolean endOfMessage) v Microsoft.AspNet.SignalR.WebSockets.DefaultWebSocketHandler.SendChunk(ArraySegment1 message)
v Microsoft.AspNet.SignalR.Infrastructure.BinaryTextWriter.<.ctor>b__6(ArraySegment`1 data, Object state)

Could you try to add this into App.config:

<system.diagnostics>

<trace autoflush="true" indentsize="0">
  <listeners>
    <add name="Global"
         type="System.Diagnostics.TextWriterTraceListener"
         initializeData="Global.log">
    </add>
  </listeners>
</trace>

<sources>
  <source name="Nowin.Core">
    <listeners>
      <remove name="Default"/>
      <add name="Nowin.Core" />
    </listeners>
  </source>
  <source name="Nowin.Core.Debug">
    <listeners>
      <remove name="Default"/>
      <add name="Nowin.Core" />
    </listeners>
  </source>
</sources>

<switches>
  <add name="Nowin.Core" value="Verbose" />
  <add name="Nowin.Core.Debug" value="Verbose" />
</switches>

<sharedListeners>
  <add name="Nowin.Core"
       type="System.Diagnostics.TextWriterTraceListener"
       initializeData="Nowin.Core.log" />
</sharedListeners>

</system.diagnostics>

Then look into global.log for exceptions ...

Also what version of SignalR you using?

I also tried simple websocket echo sample and it works without problem... So I suspect something in SignalR ...

@Bobris
Copy link
Owner

Bobris commented Feb 27, 2016

I forgot about this bug SignalR/SignalR#2720 - and it is still open ... So last signalr which worked ok is 1.x version.

@ronnieoverby
Copy link
Author

Server side (nuget package):

Client side (bower package):

"signalr": "^2.2.0"

I'll try your suggested config on Monday. Thanks.

@ronnieoverby
Copy link
Author

So looking at that ticket you referenced it doesn't seem there is going to be a fix unless I make it myself?

@Bobris
Copy link
Owner

Bobris commented Feb 28, 2016

Looks like it ... I think they will support only .Net core in future, and even SignalR will not be finished for 1.0 version. Now I expect that I will also port Nowin to .Net core after it will at least a little bit stabilize.
But it will take atleast 3 months how I see it. Though getState method does not look too difficult to implement so brace yourself and go for it :-)

@marius-klimantavicius
Copy link
Contributor

For the exception:
---> (Inner Exception #0) System.NotImplementedException: Metoda nebo operace není implementována.
v Microsoft.AspNet.SignalR.Owin.OwinWebSocketHandler.OwinWebSocket.get_State()

As a dirty work-around I have added my own OwinWebSocketContext to then environment (see: https://github.com/SignalR/SignalR/blob/master/src/Microsoft.AspNet.SignalR.Core/Owin/OwinWebSocketHandler.cs#L66)
The OwinWebSocketContext implements single property "WebSocket" (others throw NotImplementedException) that returns my custom implementation of OwinWebSocket, which is basically the same as the one in SignalR with State property implemented.

@Bobris
Copy link
Owner

Bobris commented Mar 4, 2016

Nice, thanks for sharing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants