stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
775 stars 81 forks source link

Connection errors and iframe not found #641

Closed Luiz-Otavio-Dorigon closed 1 week ago

Luiz-Otavio-Dorigon commented 1 week ago

Screenshot 2024-11-18 at 11 16 28

  1. The first error says that the WebSocket connection failed, but just below it says that it was connected. Is this correct?
  2. Soon after I get a 404 error because the iframe was not found. Why would I try to load an iframe from my API?
kum-deepak commented 1 week ago

Are you using SockJS?

Please share your configuration for the Stomp instance.

Luiz-Otavio-Dorigon commented 1 week ago

@kum-deepak Here are the libs I'm using and my connection

My dependencies: "@stomp/stompjs": "^7.0.0" "sockjs-client": "^1.6.1"

My dev dependencies "@types/sockjs-client": "^1.5.4" "@types/stompjs": "^2.3.9"

Screenshot 2024-11-18 at 13 10 36

kum-deepak commented 1 week ago

SockJS is not WebSocket (please see https://stomp-js.github.io/guide/stompjs/rx-stomp/using-stomp-with-sockjs.html).

SockJS is an emulation of WebSocket that tries multiple ways to establish a connection, one of which is to use a hidden IFrame.

kum-deepak commented 1 week ago

Another remark: you do not need "@types/stompjs": "^2.3.9". It is a for a different library. The "@stomp/stompjs" includes the type definitions.

Luiz-Otavio-Dorigon commented 1 week ago

Thank you very much @kum-deepak , with your comments I was able to solve the problem.