Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NATing SRP #67

Open
mcking230 opened this issue Jun 7, 2023 · 1 comment
Open

NATing SRP #67

mcking230 opened this issue Jun 7, 2023 · 1 comment

Comments

@mcking230
Copy link

Thank you very much for this program.
On the local network it works fine, but I wanted to forward ports and play at work and I got an error
Waiting for gamepad thread to shutdown...
Then the program started connecting to the switch on port 10060, after forwarding this port, nothing works anyway
изображение

@Moehammered
Copy link
Owner

Moehammered commented Jun 7, 2023

Hi mate, thanks for providing a diagram, it helps when dealing with these kinds of issues. However, when making this program I designed it all around local networking because providing troubleshooting support for users over WAN or internet is not something I have the time for.

In saying that, I will try my best to provide the info you need, as well as some advice. Hopefully the discussion in this issue can be used by others trying to do something similar to you.

Client and Server Communication Overview

The client (Switch app) and the server (PC app) have a set of ports they expect and use to receive and send data for the stream to function. The many parts of the stream are split into separate communication channels and are as follows:

  • Handshake Port: Used for confirming network discovery between the switch and pc
    • (irrelevant when connecting through manual IP)
  • Broadcast Port: Used for network discovery where the PC will listen on this port for a signal from the Switch app.
    • The switch app sends a signal on this port and if the PC app receives communication from this port, will initiate a handshake to finish off the network discovery
    • (irrelevant when connecting through manual IP)
  • Command Port: Used by the switch to send a command for the PC app to perform (start/stop stream).
    • Communication is one way
    • Direction: Switch --> PC
    • The PC listens for commands on this port.
  • Gamepad Port: Used by the switch to send input data to the PC app.
    • Communication is one way
    • Direction: Switch --> PC
    • The PC listens for data on this port.
  • Video Port: Used by the PC to send video frames to the Switch app.
    • Communication is one way
    • Direction: PC --> Switch
    • The Switch waits for a connection from the PC to occur, and once connected will kick off the rest of the stream processes (input, audio, etc).
    • The Switch receives video data on this port.
  • Audio Port: Used by the PC to send audio packets to the Switch app.
    • Communication is one way
    • Direction: PC --> Switch
    • The Switch creates a UDP connection and expects raw audio data to come through this port.
    • It only starts listening to data once the video stream has successfully started.

Judging from your diagram, I am guessing that while you may have forwarded the ports on one network, they aren't able to be received on the other network. Your workplace might be blocking the particular ports or have rules for inbound connections on certain ports. Regardless, things to try:

  • Make sure the PC app is configured to use the same ports as the Switch app
  • Make sure the appropriate ports are forwarded on both networks
    • From home, forward the ports that need to send data to the switch (any of the ports above marked PC --> Switch)
    • From work, forward the ports that need to send data to the PC (any of the ports above marked Switch --> PC)
  • Check to make sure there aren't any firewalls or router rules blocking any of the ports that the program uses
    • If so, try and see if you can use other ports (be sure to update the ports on both the PC and the Switch)
    • Otherwise, you will need to see if you can make rules for inbound connections for the firewall or router in place at work

Alternative Approach - Setup a VPN at Home and Connect to it (Recommended)

The above is cumbersome, and if there are firewalls or port blocking rules in place at work that you have no control over, then you're kind of out of luck. Even if you can perform the port forwarding, it is usually advised to not port forward your home network (and your work place too) since it can lead to holes in your network security.

The alternative to all of this is to setup a VPN on your home network so you can connect to your home network and act as if you are part of the LAN. This is not too difficult if you use off the shelf solutions, but it is a lot to explain and my free time is very scarce (I'm writing this before bed and it's taken 40 minutes haha).

Examples of existing VPN solutions are things like wireguard or PiVPN. However, my personal recommendation is Tailscale. I use it myself to connect to my home network (for connecting to my dev machines at home to do work) and it is a wonderful solution with a lot of documentation on how to use and configure it.

Once you have Tailscale setup on your home network, you can then set it up to act as a 'router'. From there, you can do the following:

  • Download Tailscale on your Phone
  • Connect to your VPN from your Phone
  • Enable WiFi hotspot on your Phone
  • Connect your Switch to your Phone

If done correctly, the above will make it so your Switch can communicate with your PC on your home network as if it were local to the Switch. No port forwarding required.

There's a lot of info to digest, I apologise for the wall of text. If I had free time I could probably write up a better description of how to help, but remote connections through the internet are a bit involved. What I've written though is plenty to go off and try (I believe), so I hope it leads to solving your problems. :)

Please I do ask that you attempt doing remote communication across the internet between a PC at home and a PC at work if you can to confirm that you're network setup is ready for remote connections.

I also ask anyone else seeking to perform remote connections and wanting help doing so, to try and follow the info above. I do not wish to provide support for streaming over the internet simply because it is a complex thing to explain, teach, and support. My free time is limited enough where I have no time to work on this app. Providing support on how to setup remote connections and setup VPNs is outside the scope of this app.

Thank you for your patience and understanding :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants