Project URL: https://glitch.com/edit/#!/honorable-great-position?path=hgp-client.pl%3A11%3A13
How to connect
- Download a copy of
hgp-client.pl
and run that. Even if you’re on Windows, you’re here on Glitch, which means you probably have Git, which you probably installed the Git for Windows distribution, which ships with Perl. You won’t see any output at this point. - Connect to
localhost:7777
in Terraria. - The script that’s running should output
HTTP/1.1 101 Switching Protocols
. But sometimes it takes multiple tries. Rerun the script if you need to try again, because it exits each time. - The game should connect after that.
Technical info
The connection
Glitch’s router lets you upgrade an HTTP connection and then send and receive anything. Terraria multiplayer runs on TCP. I think. I’ve found about a dozen port forwarding guides that say to forward both TCP and UDP and one obscure Reddit comment that it only uses TCP.
The client script
It just sends the HTTP upgrade request, chops off the response header, and pipes stuff from a connection on the normal Terraria port.
It’s written in Perl because that’s all I had on my Windows computer.
It only accepts a single connection and exits after the connection closes, so re-run it if you have to try multiple times. It was hard enough getting this much working in Perl.
Feel free to write up a ~5 line solution in Node.js.
HTTP 502 errors
I haven’t found out why this happens yet.
Resource limits
Even on a “Small” size world, it takes >600 MB RAM. You could try it if you boosted, I guess. But I found a user-created map that’s even smaller than that https://forums.terraria.org/index.php?threads/micro-terraria-world.884/. It comes in at ~490 MB of RAM. We’re cutting it close.
This map was created in the 1.2 era though, so it’s probably missing stuff. If anyone’s handy at Terraria modding, could I have you create a new tiny map for me? It looks like TerraCustom is able to make a smaller-than-small map, but I ran into some weird stuff where it’s looking for version 1.4.0.4 but I only have version 1.4.0.5 \:
An attempt at gracefulness
It’s supposed to save and exit when the container is going down for sleep.