I'm trying to connect a websocket server (linux machine) and client (web browser) through an intermediary server (hosted on an AWS EC2 instance). The EC2 instance provides a public IP that the websocket server and client can reference.
My client connects to ws://<SERVER>:<PORT>
, where SERVER
is the address of my EC2 instance and PORT
is an arbitrary port I've opened for port forwarding (e.g. 9111
).
On the websocket server, I'm running the following command:
/usr/bin/ssh -f -N -i $KEY -l ubuntu \
-R $PORT:127.0.0.1:9090 \
-L 9090:$SERVER:$PORT \
$SERVER
Where $KEY
is a private key for EC2 and 9090
is the port my websocket server uses. I've configured my EC2 instance's ssh daemon to enable gateway ports, and port forwarding is working just fine.
The issue comes when I try to start my websocket server -- I get an Address already in use
error, because apparently I can't start a websocket server on a port that I'm forwarding. Isn't this a fairly standard thing to do? What am I doing wrong?
Thanks!