B4J Question Websocket & Caddy reverse proxy problem

wl

Well-Known Member
Licensed User
Longtime User
Hi,

I have a test websocket application (websocket class called /connector) that works when connected directly.
Now I put a caddy webserver as a reverse proxy in between:

caddyfile:

B4X:
mydomain.com {
  proxy / http://192.168.0.2:8080 {
    websocket
  }
}

The B4J server is running on 192.168.0.2 port 80

When I connect using this caddyfile my B4J server crashes:

B4X:
  at org.eclipse.jetty.server.HttpChannelOverHttp.upgrade(HttpChannelOverHttp.java:373)java.lang.NullPointerException

When I remove the "websocket" in the caddyfile, the main page gets loaded, but as soon as the websocket is opened my browser returns an error (and thus the websocket is not working).

Anyone any idea ?

I think it is caused by the embed jetty server, as found here: http://stackoverflow.com/questions/...ocketfactory-upgrade-on-embedded-jetty-8-1-12

But I don't know how to fix it.

Thanks

Thanks !
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think it is caused by the embed jetty server, as found here:
Doesn't seem to be related to the proxy issue.

WebSocket proxy is more complicated than regular http proxy.
When I connect using this caddyfile my B4J server crashes:
Does it really crash or on the connection throws an error?

Check this issue: https://github.com/rancher/rancher/issues/4278
Looks like the fix was committed at September: https://github.com/mholt/caddy/pull/713

Make sure to use the latest version of Caddy.

Note that as an alternative you can redirect the browser to the B4J server port.
 
Upvote 0
Top