stomp-js / ng2-stompjs

Angular 6 and 7 - Stomp service over Websockets
https://stomp-js.github.io/
Apache License 2.0
182 stars 32 forks source link

Facing issue as ng2-stompjs based websocket connection is closed for a specific json object structure. It is possibly an issue with parsing of json object. #242

Closed Saumehta closed 3 years ago

Saumehta commented 3 years ago

The setup for application is as follows:

  1. FrontEnd – Angular - We are using ng2-stompJs, rxStompService with configuration done through rxStompConfig as advised in one of the tutorials.
  2. Backend – Spring Java – Configuration is done using WebSocketMessageBrokerConfigurer and registerStompEndpoints with SockJs using Simplebroker

Setup is working fine for most of the scenarios but connection is closed for 1 specific scenario. In this scenario, websocket connection gets closed for a complex json object (sample json object attached here - uwPolicyQuestions).

This json object is actually a part of a bigger complex json object which I have omitted here to simplify things here.

Also to be noted is that json object is converted to string using json.stringify before sending it.

If in this json object we make qCodeListResponses array as empty array [] it works and if we just keep qCodeListResponses and remove all other properties, it again works. Only problem is when both are there as part of object it fails.

Is there is any way to get more insights into deserializer being used in rxStomp which might be causing this.

uwpolicyQuestions.txt

kum-deepak commented 3 years ago

Please try the following:

If the above does not help, attach the output of the above logs and a copy of your configuration.

If the issue is because of large size, you may try https://stomp-js.github.io/api-docs/latest/classes/Client.html#splitLargeFrames - which is a non-standard behaviour supported only by Spring-based brokers.

Saumehta commented 3 years ago

Thanks Deepak for your revert..

We already have logRawCommunication enabled and in rxStompConfig we are also having debug function that is logging all messages.

Using SplitLargeFrames does have an impact in first run, in the sense that it made the message go through after enabling splitLargeFrames to yes. Connection was not closed by broker this time. Message sizes are big in our case and go upto 64KB. We need to do a thorough testing on what impact is splitLargeFrames having as we are seeing some unexpected errors now. We hope its not modifying/curtailing the message itself in some way. We will get back on this after doing some more testing.

Saumehta commented 3 years ago

We did some more testing and found that the solution is working fine with splitLargeFrames as yes. Thanks for all the help on this.