[stunnel-users] net::ERR_TIMED_OUT error when connecting to a websocket via stunnel

Mike Alhayek malhayek at rdicorp.com
Mon Aug 17 21:16:35 CEST 2015


Hi,
I hope someone can help me here as I have been stuck for the past 3 days.

I need to allow a client to connect to a websocket running on server 10.0.4.160 on port 8080.
I need to setup a secure tunnel to allow the client to connect to the websocket via port 58443.
I installed the latest version of stunnel on my windows Server 2008 R2. Then I changed my stunnel.conf file to look like this
[websockets]
client = yes
accept = 58443
connect = 8080
verify = 2
checkIP = 10.0.4.195
CAfile = ca-certs.pem
debug = 7
OCSPaia = yes
##The rest have been removed

I am expecting to open a connection from the user's console on port 58443 and the stunnel will allow the client to connect to port 8080
This is the code that I use in the client's console "Of course, the console is on a PC that is on my internal network"
var conn = new WebSocket('wss://10.0.4.160:58443');
conn.onopen = function(e) {
    console.log("Connection established!");
};

conn.onmessage = function(e) {
    console.log(e.data);
};
While on the server, I open up a command line and I execute this telnet localhost 8080 to open up a command line where I can see the incoming request. As soon as I fire the code above from a client javascript's console I see this in the server's command line
[cid:image001.png at 01D0D8E6.8F1CC750]



But few seconds later I get this error in the client's console

WebSocket connection to 'wss://10.0.4.160:58443/' failed: Error in connection establishment: net::ERR_TIMED_OUT

If I try to send a command using conn.sent('Hello') I get this error

VM289:2 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.

    at Error (native)

    at <anonymous>:2:6

    at Object.InjectedScript._evaluateOn (<anonymous>:905:140)

    at Object.InjectedScript._evaluateAndWrap (<anonymous>:838:34)

    at Object.InjectedScript.evaluate (<anonymous>:694:21)

Additionally, I tried to turn on debugging in strunnel by adding debug = 7 to the config file

This is what I got in the stunnel console. I don't understand what is wrong as the logs show that the client is connected but I can't send messages from the client to the server

2015.08.16 16:40:06 LOG7[36]: Service [websockets] started

2015.08.16 16:40:06 LOG5[36]: Service [websockets] accepted connection from 10.0.4.195:21963

2015.08.16 16:40:06 LOG6[36]: s_connect: connecting 127.0.0.1:8080

2015.08.16 16:40:06 LOG7[36]: s_connect: s_poll_wait 127.0.0.1:8080: waiting 10 seconds

2015.08.16 16:40:06 LOG5[36]: s_connect: connected 127.0.0.1:8080

2015.08.16 16:40:06 LOG5[36]: Service [websockets] connected remote server from 127.0.0.1:50891

2015.08.16 16:40:06 LOG7[36]: Remote socket (FD=668) initialized

2015.08.16 16:40:06 LOG6[36]: SNI: sending servername: localhost

2015.08.16 16:40:06 LOG7[36]: SSL state (connect): before/connect initialization

2015.08.16 16:40:06 LOG7[36]: SSL state (connect): SSLv2/v3 write client hello A

What am I doing wrong here? How come the connection keeps failing?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stunnel.org/pipermail/stunnel-users/attachments/20150817/8d51e553/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 69969 bytes
Desc: image001.png
URL: <http://www.stunnel.org/pipermail/stunnel-users/attachments/20150817/8d51e553/attachment-0001.png>


More information about the stunnel-users mailing list