Server send wrong connection config to clients
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 940
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 160
Description
The results of a small investigation with a non-working server...
XMage network engine (jboss lib) use two ports to connect with client (17171 for main connection and random or manual for second connection, e.g. 17172).
Server send second port and address after first connection. BUT it send his local IP, not public. That's create many problems for servers with NAT/Router.
Normal servers and games can be simple setup by port forward and it will work. And it work for xMage (partly). First connection to public IP is fine. But second connection is failed: client try to connect to local server IP and can't. What's why there are errors like:
```
"Communication error" on client log
java.lang.NullPointerException
```
[There is a workaround for NAT servers](https://www.slightlymagic.net/forum/viewtopic.php?f=70&t=15898) with adding to `hosts` file your local ip machine for public domain:
> Running the server behind a NAT-like setup
> 1) get a domain name and point it to your public IP
> 2) On your server host, edit /etc/hosts to have the domain name point to your local ip
> 3) Forward the appropriate ports (e.g. 17171 and 17172)
> 4) in your config, set serverAddress to the domain name
> 5) connect using the domain name (if you're on the local network, you'll need to add the same entry to your /etc/hosts)
But it's a bad thing. Normal admins can't figure it out. And with settings like that server can't connect to real domain and do other thinks (it's can be used non-xmage apps). Moreover, the cause of the error is not clear and difficult to find out. Issues example: #3540, #1334
Also you can't connect to NAT server by IP.
Example:
- Server public domain: server.site
- Server public IP: 80.200.125.10 (hides by NAT/Router)
- Server local IP: 192.168.0.5
- NAT setup with port forwarding (e.g. 80.200.125.10:17171 -> 192.168.0.5:17171)
- config's values for serverAddress: 192.168.0.5
- after run server start to listening two ports: 192.168.0.5:17171 and 192.168.0.5:17172
- client first connect to server.site:17171 and router forward it to 192.168.0.5:17171 -- that's ok and work;
- server send to client his config for second connect to 17172 port... and ERROR here: it 192.168.0.5:17172 -- client can't connect to local IP and close;
- to fix it you need to add `server.site 192.168.0.5` to `hosts` file on server.
**Need to fix network code to send normal domain on second connection. Maybe simple new config property for that name, like `serverAddress2`**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.