I am trying to use stunnel to turn ws into wss. Stunnel is running in client mode. It always got disconnected from remote server.

my stunnel configuration:

[websocket]
client = yes
accept = localhost:8676
connect = echo.websocket.org:443 

Then I use wsdump.py(https://github.com/liris/websocket-client) to connect it:
$ wsdump.py ws://localhost:8676
Handshake status 40

Does anyone know what's wrong?

The log file:

2014.12.22 23:13:01 LOG7[4445147136]: Service [websocket] started

2014.12.22 23:13:01 LOG5[4445147136]: Service [websocket] accepted connection from ::1:52132

2014.12.22 23:13:01 LOG6[4445147136]: s_connect: connecting 174.129.224.73:443

2014.12.22 23:13:01 LOG7[4445147136]: s_connect: s_poll_wait 174.129.224.73:443: waiting 10 seconds

2014.12.22 23:13:02 LOG5[4445147136]: s_connect: connected 174.129.224.73:443

2014.12.22 23:13:02 LOG5[4445147136]: Service [websocket] connected remote server from 192.168.1.100:52133

2014.12.22 23:13:02 LOG7[4445147136]: Remote socket (FD=10) initialized

2014.12.22 23:13:02 LOG6[4445147136]: SNI: sending servername: echo.websocket.org

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): before/connect initialization

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 write client hello A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 read server hello A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 read server certificate A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 read server done A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 write client key exchange A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 write change cipher spec A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 write finished A

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 flush data

2014.12.22 23:13:02 LOG7[4445147136]: SSL state (connect): SSLv3 read finished A

2014.12.22 23:13:02 LOG7[4445147136]:    1 items in the session cache

2014.12.22 23:13:02 LOG7[4445147136]:    1 client connects (SSL_connect())

2014.12.22 23:13:02 LOG7[4445147136]:    1 client connects that finished

2014.12.22 23:13:02 LOG7[4445147136]:    0 client renegotiations requested

2014.12.22 23:13:02 LOG7[4445147136]:    0 server connects (SSL_accept())

2014.12.22 23:13:02 LOG7[4445147136]:    0 server connects that finished

2014.12.22 23:13:02 LOG7[4445147136]:    0 server renegotiations requested

2014.12.22 23:13:02 LOG7[4445147136]:    0 session cache hits

2014.12.22 23:13:02 LOG7[4445147136]:    0 external session cache hits

2014.12.22 23:13:02 LOG7[4445147136]:    0 session cache misses

2014.12.22 23:13:02 LOG7[4445147136]:    0 session cache timeouts

2014.12.22 23:13:02 LOG7[4445147136]: Peer certificate was cached (6641 bytes)

2014.12.22 23:13:02 LOG6[4445147136]: SSL connected: new session negotiated

2014.12.22 23:13:02 LOG6[4445147136]: Negotiated TLSv1/SSLv3 ciphersuite: RC4-SHA (128-bit encryption)

2014.12.22 23:13:02 LOG6[4445147136]: Compression: null, expansion: null

2014.12.22 23:13:03 LOG7[4445147136]: SSL alert (read): warning: close notify

2014.12.22 23:13:03 LOG6[4445147136]: SSL closed (SSL_read)

2014.12.22 23:13:03 LOG7[4445147136]: Sent socket write shutdown

2014.12.22 23:13:03 LOG6[4445147136]: Read socket closed (readsocket)

2014.12.22 23:13:03 LOG7[4445147136]: Sending close_notify alert

2014.12.22 23:13:03 LOG7[4445147136]: SSL alert (write): warning: close notify

2014.12.22 23:13:03 LOG6[4445147136]: SSL_shutdown successfully sent close_notify alert

2014.12.22 23:13:03 LOG5[4445147136]: Connection closed: 184 byte(s) sent to SSL, 132 byte(s) sent to socket

2014.12.22 23:13:03 LOG7[4445147136]: Remote socket (FD=10) closed

2014.12.22 23:13:03 LOG7[4445147136]: Local socket (FD=3) closed

2014.12.22 23:13:03 LOG7[4445147136]: Service [websocket] finished (0 left)

2014.12.22 23:13:03 LOG7[4445147136]: str_stats: 3 block(s), 18446744073709549504 data byte(s), 222 control byte(s)

2014.12.22 23:13:03 LOG7[4445147136]: str_stats: 128 byte(s) at network.c:413

2014.12.22 23:13:03 LOG7[4445147136]: str_stats: 128 byte(s) at network.c:412

2014.12.22 23:13:03 LOG7[4445147136]: str_stats: 128 byte(s) at network.c:41