I am using signalR (Aspnetcore.SignalR.core v3.1.0) in one of my we application. In my local environment I am able to connect and maintain the connection between server and client. However when I deployed this app to IIS on windows server, the signalR is making connection and then automatically disconnects after 2 secs.
I tried to log the traced of both local and Server and found one discrepancy. Apart from that I am not able to find anything.
For the reference below are the traces
1. Trace from my local machine
[2022-11-17T18:56:45.702Z] Debug: Selecting transport 'WebSockets'.
Utils.ts:203 [2022-11-17T18:56:45.703Z] Trace: (WebSockets transport) Connecting.
Utils.ts:199 [2022-11-17T18:56:45.758Z] Information: WebSocket connected to ws://localhost:65109/XXXX/XXXXXXXX?id=_t1lt-2t0e0r4W5DZEmNLw.
Utils.ts:203 [2022-11-17T18:56:45.758Z] Debug: The HttpConnection connected successfully.
Utils.ts:203 [2022-11-17T18:56:45.758Z] Debug: Sending handshake request.
Utils.ts:203 [2022-11-17T18:56:45.759Z] Trace: (WebSockets transport) sending data. String data of length 32.
Utils.ts:199 [2022-11-17T18:56:45.759Z] Information: Using HubProtocol 'json'.
Utils.ts:203 [2022-11-17T18:56:45.775Z] Trace: (WebSockets transport) data received. String data of length 3.
Utils.ts:203 [2022-11-17T18:56:45.776Z] Debug: Server handshake complete.
Utils.ts:203 [2022-11-17T18:56:45.776Z] Debug: HubConnection connected successfully.
receipting.js:71 SignalR Connected.
Utils.ts:203 [2022-11-17T18:56:47.620Z] Trace: (WebSockets transport) sending data. String data of length 86.
Utils.ts:203 [2022-11-17T18:56:48.283Z] Trace: (WebSockets transport) data received. String data of length 44.
Utils.ts:203 [2022-11-17T18:57:01.219Z] Trace: (WebSockets transport) data received. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:02.640Z] Trace: (WebSockets transport) sending data. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:16.221Z] Trace: (WebSockets transport) data received. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:17.647Z] Trace: (WebSockets transport) sending data. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:31.229Z] Trace: (WebSockets transport) data received. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:32.663Z] Trace: (WebSockets transport) sending data. String data of length 11.
Utils.ts:203 [2022-11-17T18:57:46.231Z] Trace: (WebSockets transport) data received. String data of length 11.
As highlighted above in bold my connection is successful and after that, The client is sending data of length 89 and then receiving data of length 44 from server.Further The connection continues exchanging keepalive packets.
2. Traces from IIS deployed application (The one with issue)
[2022-11-18T05:51:53.718Z] Debug: Selecting transport 'WebSockets'.
Utils.ts:203 [2022-11-18T05:51:53.719Z] Trace: (WebSockets transport) Connecting.
Utils.ts:199 [2022-11-18T05:51:53.754Z] Information: WebSocket connected to ws://server Ip/Hubs/myHubName?id=XECmdzZutBdZup3AnyfzRw.
Utils.ts:203 [2022-11-18T05:51:53.754Z] Debug: The HttpConnection connected successfully.
Utils.ts:203 [2022-11-18T05:51:53.755Z] Debug: Sending handshake request.
Utils.ts:203 [2022-11-18T05:51:53.756Z] Trace: (WebSockets transport) sending data. String data of length 32.
Utils.ts:199 [2022-11-18T05:51:53.756Z] Information: Using HubProtocol 'json'.
Utils.ts:203 [2022-11-18T05:51:53.779Z] Trace: (WebSockets transport) data received. String data of length 3.
Utils.ts:203 [2022-11-18T05:51:53.780Z] Debug: Server handshake complete.
Utils.ts:203 [2022-11-18T05:51:53.780Z] Debug: HubConnection connected successfully.
receipting.js:71 SignalR Connected.
Utils.ts:203 [2022-11-18T05:51:55.691Z] Trace: (WebSockets transport) sending data. String data of length 86.
Utils.ts:203 [2022-11-18T05:51:57.746Z] Trace: (WebSockets transport) socket closed.
Utils.ts:203 [2022-11-18T05:51:57.746Z] Debug: HttpConnection.stopConnection(undefined) called while in state Connected.
Utils.ts:199 [2022-11-18T05:51:57.746Z] Information: Connection disconnected.
Utils.ts:203 [2022-11-18T05:51:57.747Z] Debug: HubConnection.connectionClosed(undefined) called while in state Connected.
Now in this case the client sends the data of length 86, However unlike the first case there is nothing sent back by server to client. And then abruptly the socket closes and connection is terminated.
I am not aware what are those data which is being exchanged between client and server. I tried going through most available documents but no luck.
I tried changing Keepalive time and clientTimeout inerval in startup.cs, however it not helping me out. I also kept default standard values but same is the behaviour.
`
services.AddSignalR(hubOptions =>
{
hubOptions.EnableDetailedErrors = true;
hubOptions.KeepAliveInterval = TimeSpan.FromMilliseconds(10000); //10 secs
hubOptions.ClientTimeoutInterval = TimeSpan.FromMilliseconds(110000); //110 secs
})
.AddJsonProtocol(options =>
{
options.PayloadSerializerOptions.PropertyNamingPolicy = null;
});
`
Can someone please help me understand this behavior?
Related
While initiating flow from spring web server by passing required values from PartyA to PartyB in corda, I am getting following exception in my initiating node PartyA, kindly do the needfull.
entered verifysend method
E 12:01:47+0530 [Thread-4 (ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$3#6cb2b947)] core.client.createConnection - AMQ214016: Failed to create netty connection
javax.net.ssl.SSLException: handshake timed out
at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
=========collecting ended=========
Even through my flow is running successfully by giving response as Transaction id:.... commited to ledger in web server, but my flow is taking around 5 minutes to create a unconsumed state.
I think you are run into low-memory issue, so one of your nodes was crashed. Hence lead to the handshake error.
The current minimal requirement for starting a node is 1GB of JVM Heap and 2GB minimal host RAM.
By using websocket open connection sampler I am making socketcluster connection. I am getting response code as 101 and response message as switching protocols and response headers as:
Response headers:
Connection: Upgrade
Sec-WebSocket-Accept: 8i/hUMajQLY5hYfg0hq9z1U1HxI=
Sec-WebSocket-Version: 13
Upgrade: websocket
WebSocket-Server: uWebSockets
I am not able to find whether it is making connection in server. In server side I am not able to see active users. Throwing some error like below:
1524146177889 - Origin: Worker (PID 14262) [Warning]
SocketProtocolError: Socket hung up
at SCSocket._onSCClose (/home/centos/jioplay/node_modules/socketcluster/node_modules/socketcluster-server/scsocket.js:240:17)
at WebSocket.internalOnClose (/home/centos/jioplay/node_modules/socketcluster/node_modules/socketcluster-server/scsocket.js:75:10)
at process.nextTick (/home/centos/jioplay/node_modules/uws/uws.js:445:27)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9
Please find attached files regarding script and results tree enter image description here.
Using spring web socket server side for constant updates from the server to client (ionic application is the client), using STOMP for connectivity.
Facing issue after getting connected. "Unhandled frame: stomp.js:134 <<< c[1007,"null"]" at client side and "com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'CONNECT': was expecting ('true', 'false' or 'null')" error is observed at server.
Console log at client side :
Opening Web Socket...
Web Socket Opened...
CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000
<<< o
Unhandled frame:
<<< c[1007,"null"]
Unhandled frame:
content-length:13
[1007,"null"]
Whoops! Lost connection to ws://127.0.0.1:8080/...
If you use SockJS with Stomp on Java Spring, you must encapsulate your Stomp frame with socket JS protocol.
for send "CONNECT\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n" + String.fromCharCode(0)
you must send this frame: "[\"CONNECT\\naccept-version:1.1,1.0\\nheart-beat:10000,10000\\n\\n\\u0000\"]"
dart code:
String data = "CONNECT\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n" + String.fromCharCode(0);
data = "[${json.encode(data)}]";
Or if you don't use Sock JS
try change (char)0 inside stomp frame by \u0000
I'm able to perform ssl & websocket handshake. The http connection is getting upgraded to websocket connection which is fine. The erlang websocket client is getting connected to the IBM Bluemix server.
But after some time I receive ssl_closed response which closes down the connection. I was sending ping request to the server and was getting response for it in binary format (which might be pong ({binary,<<10,0>>} .. haven't decoded the binary response frame).
SockReply : {ok,{sslsocket,{gen_tcp,#Port<0.2284>,tls_connection,undefined}, <0.52.0>}}
Socket : {sslsocket,{gen_tcp,#Port<0.2284>,tls_connection,undefined}, <0.52.0>} [debug] [d:6xxxxx:myFybr123:streetlight_123#172.16.1.237:57054]
SENT: CONNECT(Q0, R0, D0, ClientId=d:6xxxxx:myXXXX123:streetlight_123, ProtoName=MQTT, ProtoVsn=3, CleanSess=true, KeepAlive=300, Username=use-token-auth, Password=**)
[info] [Client <0.36.0>] connected with wss://6xxxxx.messaging.internetofthings.ibmcloud.com:443
[warning] [Client <0.36.0>] Connection lost for: ssl_closed when state is waiting_for_connack
Message : {ssl_closed, {sslsocket, {gen_tcp,#Port<0.3922>,tls_connection,undefined}, <0.74.0>}}
Why am I receiving ssl_closed after getting connected?
I wrote a websocket server in c++ that works fine with websocket protocol 00 (the one with key1, key2 in handshake header).
Now with the new update I am trying to do the same for the new way handshaking work. Here is my server response to the handshake request:
"HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + serverKey + "\r\n\r\n";
in which serverkey is computed correctly. As an example:
handshake request:
GET /test HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 192.168.123.102:8585
Sec-WebSocket-Origin: http://192.168.123.5
Sec-WebSocket-Key: YB0mPvJ5t8ggCeGUWY39uQ==
Sec-WebSocket-Version: 8
handshake response header :
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: xt9iyCNryQTseELUkHPWjzxA2ts=
I also check my algo with the example here https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-08 and it produced the exact same response.
However I still get the following error:
"Error during WebSocket handshake: Sec-WebSocket-Accept mismatch"
I am using chrome 15 as my browser.
Do you have any Idea what goes wrong?
(also in chrome inspector Network, it does not show the response which is the case when it does not accept the handshake (even with older versions))
I actually found out what was the primary problem.
the key that I used for base64 encoding was
YB0mPvJ5t8ggCeGUWY39uQ==
258EAFA5-E914-47DA-95CA-C5AB0DC85B11
instead of
YB0mPvJ5t8ggCeGUWY39uQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11
an extra \n was the whole problem.
HOWEVER, Now that I receive the Connected message (ws client is successfully connected to ws sever) I cannot send or receive anything. The problem is server side.
DO you know what are the server side changes since older websocket protocol? I only change my handshake respond and it doesnt seem enough.
There is a different framing protocol for when the client sends data. Previously it was quite simple. Now it is much more complicated. Please refer to the websockets rfc6455 spec.
https://www.rfc-editor.org/rfc/rfc6455#section-5.2