stomp-js / rx-stomp

STOMP adaptor for RxJS
Apache License 2.0
110 stars 21 forks source link

QUESTION: How to proxy RxStomp connections #546

Open jeanmelo25 opened 7 months ago

jeanmelo25 commented 7 months ago

Hi! I'm Using RxStomp, I've unsuccessfully tried various configurations to proxy a broker connection from my local app to a remote backend server. Has anyone achieved this RxStomp proxy setup? Any guidance? Thanks!

My last proxy config

  "/myPath/core/ws": {
    "target": "https://my-remote-address",
    "ws": true,
    "secure": true,
    "changeOrigin": true,
    "logLevel": "debug"
  },
mcpierce commented 5 months ago

@jeanmelo25 I'm having a similar issue now. What I see is my server logging Completed 400 BAD_REQUEST each time my Angular app tries to connect to it via the proxy configuration.

Did you get yours to work and, if so, what did you do?

jeanmelo25 commented 5 months ago

@mcpierce It is impossible to test locally with rx-stomp. To do so, connect to another WS without rx-stomp, run tests, and then try with rx-stomp in a productive environment.

kum-deepak commented 5 months ago

I am not sure which software you are using to proxy. We use Nginx to proxy rx-stomp connections. The instructions we used are at https://nginx.org/en/docs/http/websocket.html

In addition, I am unaware of any limitation of using rx-stomp for testing in a local environment. This project itself uses a broker running in a local machine during testing.

jeanmelo25 commented 5 months ago

I'm proxying to my backend in a productive environment directly from Angular served locally. It's simply impossible. I've tried multiple proxy configurations unsuccessfully.

mcpierce commented 5 months ago

I am not sure which software you are using to proxy. We use Nginx to proxy rx-stomp connections. The instructions we used are at https://nginx.org/en/docs/http/websocket.html

For Angular apps, during development, you can tell the Angular server how to proxy connections to the backend services using a proxy configuration file like @jeanmelo25 describes in the original post. That proxying is so that you make changes to the code without having to do a full deployment to test the changes.

In addition, I am unaware of any limitation of using rx-stomp for testing in a local environment. This project itself uses a broker running in a local machine during testing.

In my case, I think the whole scenario is nearly working in that the Angular proxy is forwarding the packets to my backend server. We use this same setup in our existing implementation without issue. The problem only manifests when we try to replace our old implementation, which uses webstomp-client, with rx-stomp.