farirpgs / fari-app

The Free and Open-Source VTT
https://fari.app/
GNU Affero General Public License v3.0
290 stars 56 forks source link

Can't connect from the same network #229

Open aravol opened 3 years ago

aravol commented 3 years ago

🚩 Describe the bug

Two machines connected from the same LAN cannot connect to each other over Fari

🔢 Steps to reproduce

Host a table from Machine A Copy Link, send to Machine B Join game from Machine B Enter name on name page Wait... Client console shows PeerJS: iceConnectionState changed to disconnected on the connection with <GUID> Note <GUID> does NOT match the link guid Server Console does not appear to acknowledge the connection attempt

🟢 Expected behavior

App connects or displays a clear error

🔴 Actual behavior

App never stops "loading" spinner

💅 Screenshots

image

🖥 Desktop or Smartphone

📄 Additional context

jmicu commented 3 years ago

I have the same issue sometimes.

My usual workaround is to click Join repeatedly until it finally does so. It has worked every time, but the number of clicks needed varies

aravol commented 3 years ago

Going by this workaround, it should be noted that everyone else from outside my LAN was able to connect without incident

RPDeshaies commented 3 years ago

Interesting. I tried joining from the same browser, the same computer and even the same network using my computer and my phone (same wifi) and it's working fine so I will need to investigate a bit more to see if there's a fix for this.

aravol commented 3 years ago

Same result tonight. I might try pulling down a dev environment, but this is a complete dealbreaker for our campaign

RPDeshaies commented 3 years ago

@aravol I investigated a bit more, and I just tested with multiple computers in my house and I sadly cannot reproduce this issue.

I think it could be isolated to the way your network/router/ISP is configured but its pretty hard for me to pinpoint.

It could also be related to this: https://github.com/fariapp/fari/wiki/Connection-issues

But since I cannot reproduce it on my end, I will need help to help find more details about this issue.

For now, I would recommend you use the offline mode and share your screen while players look at their character sheet on their end.

If that still doesn't work for you, well I'm sorry that it is a dealbreaker for your campaign. I hope that one day the WebRTC protocol is going to be more stable, but this is out of my hands.

trb1maker commented 3 years ago

A similar problem. The error message does not appear, but in the console the message is:

WebRTC: ICE failed, your TURN server appears to be broken, see about:webrtc for more details
PeerJS:  iceConnectionState is failed, closing connections to bf01a645-1945-49c0-9b08-6138385d20a4 instrument.ts:129:35

Can I help figure out the reason? console-export-2021-3-6_21-6-27.txt

aaronanderson-github commented 3 years ago

I encountered the same problem on Chrome on MacOS version 10.15.7 (Catalina), but clicking 'Join' repeatedly wasn't working. The problem may have something to do with anonymizing the local IPs exposed by WebRTC.

Workaround

I've found disabling anonymizing local IP addresses in your browser allows you connect. I'm no expert, but using these workarounds is a potential security concern, hence why the browsers are the set the way they are. If you insist of doing this, I advise you to use this workaround for the duration of playing then change it back.

This workaround may need to be done for both computers on your network, not just the one that can't connect.

Chrome

  1. type chrome://flags into your address bar at the top of the browser
  2. Search for Anonymize local IPs exposed by WebRTC in the search bar
  3. Set "Anonymize local IPs exposed by WebRTC" to Disable
  4. Relaunch Chrome and connect to the fari game

    Firefox

    Someone else may confirm this, but I believe the following steps are equivalent to the above Chrome workaround if you're encountering a problem using Firefox:

  5. type about:config in your address bar
  6. If "Proceed with Caution" appears, click Accept Risk and Continue
  7. Type in media.peerconnection.ice.obfuscate_host_addresses into the search bar
  8. Click the toggle button on the far right of media.peerconnection.ice.obfuscate_host_addresses so the value is changed to false
  9. Relaunch Firefox and connect to the fari game

    On an potentially related note, comparing the console output of a successful connection against one that doesn't connect, I've found the successful one contains two additional lines: instrument.ts:129 PeerJS: DC#dc_mcrc5mgzl3 dc connection success situated before the "Server message received" messages and, instrument.ts:129 PeerJS: DC#dc_mcrc5mgzl3 dc onmessage: ArrayBuffer(4961) after the "Server message received" messages. Whether this is helpful or not I'm not certain.

aravol commented 3 years ago

Was able to get it working with this above anonymization workaround, though it didn't work on only the host machine; needed to be applied to both machines

aaronanderson-github commented 3 years ago

Was able to get it working with this above anonymization workaround, though it didn't work on only the host machine; needed to be applied to both machines

Noted, I'll add that to the workaround. Were both machines using the same browser to connect to the session? Such as both using Chrome?

RPDeshaies commented 3 years ago

This is a very nice investigation @FastCarrot and happy to see that it worked for you @aravol !

Perhaps this workaround could be added to the wiki so that everyone can benefit from this ? We could also include a link to the flag directly for chrome like chrome://flags/#enable-webrtc-hide-local-ips-with-mdns

https://github.com/fariapp/fari/blob/master/docs/fari-wiki.md#connection-issues

RPDeshaies commented 3 years ago

I still find it weird that this flag is needed only for certain users and not all of them. I'm no network expert so if anyone knows and would like to enlighten me, please do.

klashe1977 commented 3 years ago

Hello, I'm having the same issue. Two computers, same LAN, cannot connect to each other. I also tried having one of the computers connect to a VPN, and same issue occurred.

My workaround was to set up a local hotspot on my phone and have one player connect to that hotspot. Then I was able to establish the connection.