GithubHelp home page GithubHelp logo

Comments (5)

chj113 avatar chj113 commented on August 16, 2024 1

@aaugustin
Thanks for your help!
When I modified it to the following code, it started working properly.
I hope it will be helpful to others.
heart-beat:4000,10000 -> heart-beat:0,0

connect_frame = (
                'CONNECT\n'
                'accept-version:1.2,1.1,1.0\n'
                'heart-beat:0,0\n'
                f'Authorization:{token}\n'
                '\n'
                '\x00'
            )

from websockets.

aaugustin avatar aaugustin commented on August 16, 2024

The server is closing the connection, as shown here in the log:

DEBUG:websockets.client:< CLOSE 1002 (protocol error) [2 bytes]

Maybe the server logs say why it's closing the connection?

from websockets.

chj113 avatar chj113 commented on August 16, 2024

No error found in server logs.Other stomp clients like stompjs connect to the same server work well. After I turned off the server's heartbeat, this error no longer exists.but the connection closed after a few minites.

from websockets.

chj113 avatar chj113 commented on August 16, 2024

The server is closing the connection, as shown here in the log:

DEBUG:websockets.client:< CLOSE 1002 (protocol error) [2 bytes]

Maybe the server logs say why it's closing the connection?

server log like this: LoggingWebSocketHandlerDecorator closed with CloseStatus[code=1002, reason=null]
It looks like a protocol error. https://stackoverflow.com/questions/65269411/websocket-closes-with-protocol-error-1002
Can y give me a demo that websockets works over stomp?thanks...

from websockets.

aaugustin avatar aaugustin commented on August 16, 2024

Try adding ping_interval=None instead of ping_interval=5. If that works, then the problem could be that the server attempts to UTF-8-decode the payload of pings, which is incorrect — nothing says that ping payloads must be valid UTF-8 — but I've seen that before.

The logs that you posted don't corroborate this theory fully. The first ping payload becomes invalid UTF-8 in the fourth byte, while the second ping payload is invalid at the first byte. Still, the fact that the error happens at a different point might cause different behavior.

>>> b"\x7e\x7e\x1d\x92".decode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 3: invalid start byte
>>> b"\xc4\xf5\xce\x9a".decode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte

Can y give me a demo that websockets works over stomp?

I'm not familiar with STOMP. What I see in the logs is a completely valid WebSocket session. From the perspective of the WebSocket RFC, websockets does the right thing. Really the question is "what does the server dislike?"

from websockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.