locked
SignalRAndroid RRS feed

  • Question

  • User98396162 posted

    Recent Android project using SignalR messaging, when the first connection request need to add the head, but there is no such method, try to concatenate field added to the queryString, unexpectedly successful connection to the Server, but then found communication mode "Websocket became ServesentEvent, this Server will not be pushed to the client.Is there any way to solve it?

    This is a log:

    12-09 11:25:01.806 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=URL: http://192.168.1.115:1001/socket/signalr/negotiate?clientProtocol=1.3&connectionData=%5B%7B%22name%22%3A%22userservice%22%7D%5D&Bearer=Va4dxQRq3lfg_z4VUAi0h4GiRIJrXAmnx-4U69qyZ22NEhv5xiYzNQJgWNKP6AUma6Rry7Oxl-KYsh2nSRCZ3mdPOOeada2fIGHV1_Xfg2rOL9qr8Fbq9US1Djs2NZGbOHOUcVVR2ceJIe6IeA_IwuMuj39k05CIt8-hpKyR2m7JXkjGdGoz51jdvBbYuDFGvWCMVxx-E1DGCzmUmcQGthCKFhAj5t1qOVLFxqT7vYd7LyagAkIJqAljC_SJnS8tzgcip7u-AlzTJ1sSqGfvvar7qlAYcwkNrw6NxPpXFbeueLN2aVkcSCK5gHHcukauSfmUcmO1FeinmCWzUjuIk0PLPZHkvPo72BPvW6VP3BVeFCPYYLuLZr-Of87WjEN-tff1MJwuXJHTW-tPGShYy4AfILnHb-IDh6I3pjb6JgHwi5le2GHMv0U25gUM-JmpcBScAXQGwjaW9ZKCQcevQLBK3LtWCIBQR-h5lrEnfWOubV-XtW6FGm0inbFWlfIfPzWn2w&epd=3&devid=99001083837767

    12-09 11:25:01.806 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=VERB: GET

    12-09 11:25:01.807 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Header User-Agent: SignalR (lang=Java; os=android; version=2.0)

    12-09 11:25:01.807 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=CONTENT: null

    12-09 11:25:01.811 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Request executed

    12-09 11:25:01.843 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=AutomaticTransport - Response received

    12-09 11:25:01.843 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=AutomaticTransport - Read response data to the end

    12-09 11:25:01.846 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=AutomaticTransport - Trigger onSuccess with negotiation data: {"Url":"/socket/signalr","ConnectionToken":"YI02LJUe20vOXEIgveoJz4Pqt53Ci2TCwMghEiilWsGIXlXnkS/c4RXcVPAaml+4R7B4KS1PR4HUfxs8PCU2dEGGPihJpc0B2jlTwg==","ConnectionId":"22348352-b3dc-46e8-94f9-a86b17cce760","KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.3","TransportConnectTimeout":30.0,"LongPollDelay":0.0}

    12-09 11:25:01.853 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Negotiation completed

    12-09 11:25:01.854 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - ConnectionId: 22348352-b3dc-46e8-94f9-a86b17cce760

    12-09 11:25:01.854 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - ConnectionToken: YI02LJUe20vOXEIgveoJz4Pqt53Ci2TCwMghEiilWsGIXlXnkS/c4RXcVPAaml+4R7B4KS1PR4HUfxs8PCU2dEGGPihJpc0B2jlTwg==

    12-09 11:25:01.855 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Keep alive timeout: 20.0

    12-09 11:25:01.856 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Entered startLock in startTransport

    12-09 11:25:01.856 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Starting the transport

    12-09 11:25:01.859 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Starting transport for InitialConnection

    12-09 11:25:01.860 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Start the communication with the server

    12-09 11:25:01.862 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Getting connection data: [{"name":"userservice"}]

    12-09 11:25:01.863 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Execute the request

    12-09 11:25:01.865 1912-3045/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Create new thread for HTTP Connection

    12-09 11:25:01.867 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Execute the HTTP Request

    12-09 11:25:01.867 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=URL: http://192.168.1.115:1001/socket/signalr/connect?transport=serverSentEvents&connectionToken=YI02LJUe20vOXEIgveoJz4Pqt53Ci2TCwMghEiilWsGIXlXnkS%2Fc4RXcVPAaml%2B4R7B4KS1PR4HUfxs8PCU2dEGGPihJpc0B2jlTwg%3D%3D&connectionId=22348352-b3dc-46e8-94f9-a86b17cce760&connectionData=%5B%7B%22name%22%3A%22userservice%22%7D%5D&Bearer=Va4dxQRq3lfg_z4VUAi0h4GiRIJrXAmnx-4U69qyZ22NEhv5xiYzNQJgWNKP6AUma6Rry7Oxl-KYsh2nSRCZ3mdPOOeada2fIGHV1_Xfg2rOL9qr8Fbq9US1Djs2NZGbOHOUcVVR2ceJIe6IeA_IwuMuj39k05CIt8-hpKyR2m7JXkjGdGoz51jdvBbYuDFGvWCMVxx-E1DGCzmUmcQGthCKFhAj5t1qOVLFxqT7vYd7LyagAkIJqAljC_SJnS8tzgcip7u-AlzTJ1sSqGfvvar7qlAYcwkNrw6NxPpXFbeueLN2aVkcSCK5gHHcukauSfmUcmO1FeinmCWzUjuIk0PLPZHkvPo72BPvW6VP3BVeFCPYYLuLZr-Of87WjEN-tff1MJwuXJHTW-tPGShYy4AfILnHb-IDh6I3pjb6JgHwi5le2GHMv0U25gUM-JmpcBScAXQGwjaW9ZKCQcevQLBK3LtWCIBQR-h5lrEnfWOubV-XtW6FGm0inbFWlfIfPzWn2w&epd=3&devid=99001083837767

    12-09 11:25:01.867 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=VERB: GET

    12-09 11:25:01.868 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Header User-Agent: SignalR (lang=Java; os=android; version=2.0)

    12-09 11:25:01.868 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Header Accept: text/event-stream

    12-09 11:25:01.869 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=CONTENT: null

    12-09 11:25:01.870 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=Request executed

    12-09 11:25:01.884 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Response received

    12-09 11:25:01.884 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Entered startLock after transport was started

    12-09 11:25:01.885 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Current state: Connecting

    12-09 11:25:01.885 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Starting Heartbeat monitor

    12-09 11:25:01.887 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Connected

    12-09 11:25:01.888 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Read the response content by line

    12-09 11:25:01.889 1912-1912/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubProxy UserService - Subscribe to event serverSay

    12-09 11:25:01.889 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Found new data: data: initialized

    12-09 11:25:01.890 1912-1912/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubProxy UserService - Creating new subscription for: serversay

    12-09 11:25:01.890 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=serverSentEvents - Initialization message found

    12-09 11:25:01.892 1912-1912/com.damei.okmoney I/hub: 连接·成功

    Friday, December 8, 2017 6:51 AM

All replies

  • User61956409 posted

    Hi perfectlisir,

    perfectlisir

    "KeepAliveTimeout":20.0,"DisconnectTimeout":30.0,"ConnectionTimeout":110.0,"TryWebSockets":true,"ProtocolVersion":"1.3"

    According to the log, I just find you set "TryWebSockets":true", but it seems that either your client or server do not support WebSocket, it uses Server Sent Events as transport.

    perfectlisir

    12-09 11:25:01.885 1912-3047/com.damei.okmoney I/SignalRService.java: (SignalRService.java:103).log:socke=HubConnection - Current state: Connecting

    Your client seems lost the connection and re-establish the connection after it connected, you can try to broadcast message to all clients and check if only that reconnected client misses the message.

    Besides, please start connection without passing value via QueryString and check if your project works fine (maybe other factor cause the issue).

    With Regards,

    Fei Han

    Monday, December 11, 2017 2:40 AM
  • User98396162 posted

    Hi  Fei Han,

    Thank you very much for your answer!<o:p></o:p>

    The iOS side USES WebSocket transmission mode to chat normally, and the server supports WebSocket. "TryWebSockets":true" is SignalR set at the bottom, and I can't set it.At present, my project (Android) can run normally, Server actively push the client can receive the news, but the transport is the Server Sent the Event, the Server push regularly, consuming resources, so I want to ask you is there any method can solve, will transport by ServerSentEvent change for WebSocket, look forward to your comment!

    With Regards,

    perfectlisir

    <o:p></o:p>

    Monday, December 11, 2017 9:10 AM
  • User61956409 posted

    Hi perfectlisir,<o:p></o:p>

    Your server supports WebSocket, and if you’re sure that the client also supports WebSocket, you can try to specify transport. <o:p></o:p>

    $.connection.hub.start( { transport: 'webSockets' });

    With Regards, <o:p></o:p>

    Fei Han<o:p></o:p>

    Monday, December 11, 2017 9:22 AM