BlueBubblesApp / bluebubbles-server

Server for forwarding iMessages to clients within the BlueBubbles App ecosystem

Home Page:https://bluebubbles.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't connect to server using custom URLs

bobbyl140 opened this issue · comments

I tried entering a custom URL (https://bb.example.com) that points to my inbound proxy, which the client initially seems to take, but while trying to sync messages it gives up before it even starts with a message that the server is offline. The same thing happens when using the LAN URL of http://<mac>:1234. I tried it using Cloudflare and it worked immediately, but I don't wish to use a third party service for this.

can you hit your LAN URL address in your browser?

Yeah, both the LAN URL and that of the proxy are visible with Welcome to the BlueBubbles Server landing page!

and just to confirm, when you are on your WiFi, the same one that your Mac is on, you are unable to connect to BlueBubbles using the LAN URL?

Also correct, it's reachable in a browser from all networks, and reachable from the client on no network.

May have found the problem: I use a VPN called Tailscale, and when I just now tried connecting to the VPN IP, it worked. My guess is that that IP is assumed to be the LAN IP and the physical one doesn't get listened on. Is there a way I could override that? Or just listen on 0.0.0.0?

EDIT: But the browser can reach it. I don't know what's going on...

I can use my original inbound proxy setup and forward to the VPN IP, so I guess this is no longer an issue for me, but this could be a potential problem in the future.

EDIT: I changed the proxy to the VPN IP, and it does begin to sync, but then it says the server is offline and gives up.
EDIT 2: I can reopen the app and it shows messages, but this is the connection status:
Screenshot 2024-01-31 at 5 09 01 PM
I assume I'm doing something wrong with my proxy setup.

May have found the problem: I use a VPN called Tailscale, and when I just now tried connecting to the VPN IP, it worked. My guess is that that IP is assumed to be the LAN IP and the physical one doesn't get listened on. Is there a way I could override that? Or just listen on 0.0.0.0?

EDIT: But the browser can reach it. I don't know what's going on...

Yeah, super odd, but good call out. Right now, the listening code is just: https://github.com/BlueBubblesApp/bluebubbles-server/blob/master/packages/server/src/server/api/http/index.ts#L217

Looks like I can add a hostname after the port, and should be able to set it to 0.0.0.0. Might fix the issue? I'm not 100% sure what it defaults to. This SO post indicates that maybe it already defaults to 0.0.0.0, or maybe localhost... Not super clear:

https://stackoverflow.com/questions/33953447/express-app-server-listen-all-interfaces-instead-of-localhost-only

No harm in explicitly setting the hostname though. it won't go out in the next beta release coming today most likely, but will be in the final release

I can use my original inbound proxy setup and forward to the VPN IP, so I guess this is no longer an issue for me, but this could be a potential problem in the future.

EDIT: I changed the proxy to the VPN IP, and it does begin to sync, but then it says the server is offline and gives up. EDIT 2: I can reopen the app and it shows messages, but this is the connection status: Screenshot 2024-01-31 at 5 09 01 PM I assume I'm doing something wrong with my proxy setup.

Maybe your proxy is not forwarding websocket stuff? im not totally sure, but I'm leaning towards an environment/setup issue. Maybe the hostname change will fix it, but I don't think so (for the socket disconnect issue specifically)

I'm not sure either, I just checked and the module for proxying websockets is enabled. I have had a few other minor problems with my setup, so I'm sure there's something I'm not doing. But thanks anyways, sorry for the false issue.

Although wait, I might know what's wrong. I am proxying with an http:// URL, and not a ws:// one. Is there a path that the websocket follows that I can statically proxy? If I need to proxy / then I'm not sure what to do.

Still not sure about the LAN URL thing, but what you said about adding a hostname might do it.

Although wait, I might know what's wrong. I am proxying with an http:// URL, and not a ws:// one. Is there a path that the websocket follows that I can statically proxy? If I need to proxy / then I'm not sure what to do.

Still not sure about the LAN URL thing, but what you said about adding a hostname might do it.

That, I'm not sure of. We don't utilize a specific URL path for websocket connections.

That, I'm not sure of. We don't utilize a specific URL path for websocket connections.

Well I got it working with the LAN IP, I realize now if I ever need remote access I always have SSH port forwarding. My overall suggestion for this kind of setup though, is maybe put the websocket at (say) /ws/ just so that you could do something like:

ProxyPass /ws ws://10.0.0.2:1234/ws/
ProxyPassReverse /ws ws://10.0.0.2:1234/ws/

ProxyPass / http://10.0.0.2:1234/
ProxyPassReverse / http://10.0.0.2:1234/

Without the ability to separate HTTP and Websocket connections, AFAIK you can do it by matching proxy rules to protocol, as in the following pseudocode:

if "http(s)://*":
  proxy to http://10.0.0.2

if "ws(s)://*":
  proxy to ws://10.0.0.2

I will try actually writing that when I'm fresh tomorrow morning and report back. But at this point the issue is clearly user error.

That, I'm not sure of. We don't utilize a specific URL path for websocket connections.

Well I got it working with the LAN IP, I realize now if I ever need remote access I always have SSH port forwarding. My overall suggestion for this kind of setup though, is maybe put the websocket at (say) /ws/ just so that you could do something like:

ProxyPass /ws ws://10.0.0.2:1234/ws/
ProxyPassReverse /ws ws://10.0.0.2:1234/ws/

ProxyPass / http://10.0.0.2:1234/
ProxyPassReverse / http://10.0.0.2:1234/

Without the ability to separate HTTP and Websocket connections, AFAIK you can do it by matching proxy rules to protocol, as in the following pseudocode:

if "http(s)://*":
  proxy to http://10.0.0.2

if "ws(s)://*":
  proxy to ws://10.0.0.2

I will try actually writing that when I'm fresh tomorrow morning and report back. But at this point the issue is clearly user error.

I looked into it some more and found out, at least according to this link, that the websocket path is (by default) /socket.io/

https://socket.io/docs/v3/server-api/

Do you think you could try using that for your reverse proxy?

Give me 5 minutes to set that in the config, and I'll report back.

Sorry that took a while, I had some trouble configuring Apache. I did get it to work, with the following config (snippet):

        ProxyPass / http://(IP):(port)/
        ProxyPassReverse / http://(IP):(port)/

        RewriteCond %{HTTP:Upgrade} =websocket
        RewriteRule /socket.io/(.*) ws://(IP):(port)/socket.io/$1 [P,L]

It was in fact user error. Thank you so much for helping me debug though!