mattrossman / hmd-link

Send links to your XR headset, hassle free.

Home Page:https://hmd.link

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hanging on "Connecting..." instead of having a room name

Utopiah opened this issue · comments

Hi there, not sure why unfortunately but across devices (desktop with different OS, Quest, AVP, etc) I'm often getting not room name. Sometimes it happens I'm behind a VPN but most often not. This wasn't ever the cast until few weeks ago somehow.

FWIW just tried on AVP, no VPN, and hanging on "Connecting..." instead of having a room name. On desktop over the same WiFi I do get a room name within seconds.

I can reproduce this.

Some context: a couple weeks ago I changed the DNS to point to CloudFlare (experimenting with PartyKit). That wound up screwing up the Netlify headers that I rely on to determine room assignment leading to weird behavior where two devices on the same network would report different, constantly changing room names.

I fixed that here by checking a different header provided by CloudFlare. While I was at it I tried fixing another timing issue that I've been experiencing for a couple years, where sometimes when I open the site on a new network I'll connect but the room name is empty.

The error I see now in the Netlify logs from the auth function is

{"code":"auth/user-not-found","message":"There is no user record corresponding to the provided identifier."}

I think the change here triggered the issue of it no longer connecting. I suspect that previously it would silently fail since I ignored the Promise, but now the error actually gets raised. I didn't notice this earlier because the "user" for my home IP already existed in Firebase, but when I test on a different IP it breaks. It looks like I should be calling createUser instead of updateUser here. I'm a little busy today but I'll make a fix for this soon.

@Utopiah I deployed a fix, let me know if it resolved the issue for you. It works on my end at least but would be worth testing on a fresh IP to make sure the createUser stuff is working as intended.

Thanks, I did get a room name right away this time... but I get a different one than from the desktop.

Huh, I am getting matching rooms. If it doesn't fix itself after a (hard) refresh on both devices, could you check the output of https://hmd.link/.netlify/functions/debug ? That will output the raw event that I get from Netlify. Specifically the part to check is the "headers" section of this object.

I expect on both devices, a "cf-connecting-ip" header should be present and contain your public IP (as verified on https://www.whatismyip.com/ for instance).

If that isn't the case, could you let me know if any other headers are present that contain the correct IP for both devices?

On my desktop I get my IPv4 in that field while on HMD I get IPv6

I just disabled the "Proxy" feature that CloudFlare auto-enables in its DNS records. I suspect that's the thing that is messing with the headers, and might be the reason for the server accepting IPv6 addresses from your HMD.

Before doing this what I observed was:

  • cf-connecting-ip contains my IPv4 address
  • x-forwarded-for contains my IPv4 address followed by a CloudFlare datacenter IPv4 address
  • x-nf-client-connection-ip contains a CloudFlare datacenter IPv4 address

After the change:

  • x-forwarded-for contains my IPv4 address
  • x-nf-client-connection-ip contains my IPv4 address

This matches how things used to work prior to a couple weeks ago, so hopefully this means all the CloudFlare interference has been undone.

Give it another go, and if that doesn't work let me know if any other headers (e.g. x-forwarded-for) report matching IP addresses between your devices.

Working again now, thanks!