Connection problem with secured WebSocket on embedded linux



  • Hello,

    I have a problem on an application developed on an embedded linux. This application creates a WebSocket server, which is then, used on a WebApp. The version of Qt used is 5.4.1 (We are about to migrate to 5.6.2, but it is not planned for the moment).

    Everything works fine, until I switched on a SSL WebSocket server. Now, with the secured WebSocket, when I try to connect with an IPhone 4S with Chrome, the connection to the WebSocket fails. That's the first problem.

    But the second problem is the one which is really problematic : After the failed connection done with the IPhone, the WebSocket server refuses all the others connections. Only the re-creation of the object QWebSocketServer() can solve the problem (this is not a solution....).

    I have investigated the problem in order to see what is wrong. First of all, after the failed connection, the command "netstat -a" shows that the Receive Queue of the socket increases progressively. It seems to not be unstacked anymore (See the port 9475) :

    ~ # netstat -a
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State
    tcp        0      0 0.0.0.0:9474            0.0.0.0:*               LISTEN
    tcp       24      0 0.0.0.0:9475            0.0.0.0:*               LISTEN
    tcp        0      0 0.0.0.0:www             0.0.0.0:*               LISTEN
    tcp        0      0 0.0.0.0:domain          0.0.0.0:*               LISTEN
    tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
    tcp        0      0 0.0.0.0:https           0.0.0.0:*               LISTEN
    tcp        0      0 192.168.86.14:ssh       192.168.86.26:49049     ESTABLISHED
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48750     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48556     CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:37746    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48550     CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:38254    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48534     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48734     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48668     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48674     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48632     CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:37576    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48590     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48562     CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:38094    CLOSE_WAIT
    tcp      181      0 192.168.43.30:9475      192.168.43.100:60188    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48720     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48570     CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48726     CLOSE_WAIT
    tcp        0      0 192.168.43.30:9475      192.168.43.100:59923    ESTABLISHED
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48582     CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:37910    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48576     CLOSE_WAIT
    tcp        0      0 192.168.86.14:ssh       192.168.86.10:32777     ESTABLISHED
    tcp      518      0 192.168.43.30:9475      192.168.43.186:38586    CLOSE_WAIT
    tcp      518      0 192.168.43.30:9475      192.168.43.186:38428    CLOSE_WAIT
    tcp      518      0 192.168.86.14:9475      192.168.86.10:48664     CLOSE_WAIT
    netstat: /proc/net/tcp6: No such file or directory
    udp        0      0 0.0.0.0:34356           0.0.0.0:*
    udp        0      0 0.0.0.0:domain          0.0.0.0:*
    udp        0      0 0.0.0.0:bootps          0.0.0.0:*
    udp        0      0 0.0.0.0:46804           0.0.0.0:*
    udp        0      0 0.0.0.0:5353            0.0.0.0:*
    netstat: /proc/net/udp6: No such file or directory
    netstat: /proc/net/raw6: No such file or directory
    Active UNIX domain sockets (servers and established)
    Proto RefCnt Flags       Type       State         I-Node Path
    unix  2      [ ACC ]     STREAM     LISTENING        809 /tmp/var/run/avahi-daemon/socket
    unix  2      [ ]         DGRAM                       600 /var/run/wpa_supplicant/wlan0
    unix  12     [ ]         DGRAM                       219 /dev/log
    unix  2      [ ]         DGRAM                      1206
    unix  2      [ ]         DGRAM                      1181
    unix  2      [ ]         DGRAM                      1102
    unix  2      [ ]         DGRAM                       919
    unix  2      [ ]         DGRAM                       896
    unix  2      [ ]         DGRAM                       859
    unix  2      [ ]         DGRAM                       821
    unix  2      [ ]         DGRAM                       805
    unix  2      [ ]         DGRAM                       788
    unix  2      [ ]         DGRAM                       689
    

    Next, I tried to activate the logs in QSslSocket class and QSslSocketBackendPrivate class, in order to see what is wrong. Here are the logs :
    When I succeed in connecting to the Secured WebSocket (for example, with my PC) :

    QSslSocket::QSslSocket( QObject(0x0)  ), this = 0x234608
    QSslSocket::setSocketDescriptor( 17 , QAbstractSocket::ConnectedState , OpenMode( "ReadOnly|WriteOnly" ) )
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::ConnectedState )
    QSslSocket::startServerEncryption()
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_readyReadSlot() - 517 bytes available
    QSslSocketBackendPrivate::transmit: read 517 encrypted bytes from the socket
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: wrote 2090 encrypted bytes to the socket 2090 actual.
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_bytesWrittenSlot( 2090 )
    QSslSocket::_q_readyReadSlot() - 126 bytes available
    QSslSocketBackendPrivate::transmit: read 126 encrypted bytes from the socket
    QSslSocketBackendPrivate::transmit: testing encryption
    onNewConnection event
    manage one pending connection
    Is socket contains data : 
    QSslSocketBackendPrivate::transmit: encryption established
    QSslSocketBackendPrivate::transmit: wrote 242 encrypted bytes to the socket 242 actual.
    QSslSocket::_q_bytesWrittenSlot( 242 )
    QSslSocket::_q_errorSlot( QAbstractSocket::RemoteHostClosedError )
    	state = QAbstractSocket::ConnectedState
    	errorString = "Unknown error"
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::ClosingState )
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::UnconnectedState )
    QSslSocket::_q_disconnectedSlot()
    	state = QAbstractSocket::UnconnectedState
    QSslSocket::QSslSocket( QObject(0x0)  ), this = 0x240bd0
    QSslSocket::setSocketDescriptor( 17 , QAbstractSocket::ConnectedState , OpenMode( "ReadOnly|WriteOnly" ) )
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::ConnectedState )
    QSslSocket::startServerEncryption()
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_readyReadSlot() - 517 bytes available
    QSslSocketBackendPrivate::transmit: read 517 encrypted bytes from the socket
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: wrote 2090 encrypted bytes to the socket 2090 actual.
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_bytesWrittenSlot( 2090 )
    QSslSocket::_q_readyReadSlot() - 126 bytes available
    QSslSocketBackendPrivate::transmit: read 126 encrypted bytes from the socket
    QSslSocketBackendPrivate::transmit: testing encryption
    

    When I try to connect with the IPhone :

    QSslSocket::QSslSocket( QObject(0x0)  ), this = 0x233158
    QSslSocket::setSocketDescriptor( 17 , QAbstractSocket::ConnectedState , OpenMode( "ReadOnly|WriteOnly" ) )
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::ConnectedState )
    QSslSocket::startServerEncryption()
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_readyReadSlot() - 180 bytes available
    QSslSocketBackendPrivate::transmit: read 180 encrypted bytes from the socket
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: wrote 2118 encrypted bytes to the socket 2118 actual.
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocketBackendPrivate::transmit: testing encryption
    QSslSocketBackendPrivate::transmit: encryption not done yet
    QSslSocket::_q_bytesWrittenSlot( 2118 )
    QSslSocket::_q_errorSlot( QAbstractSocket::RemoteHostClosedError )
    	state = QAbstractSocket::ConnectedState
    	errorString = "Unknown error"
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::ClosingState )
    QSslSocket::_q_stateChangedSlot( QAbstractSocket::UnconnectedState )
    QSslSocket::_q_disconnectedSlot()
    	state = QAbstractSocket::UnconnectedState
    

    And after that, there is no log anymore when I try to connect with my PC, and the Received Queue of the secured WebSocket increase progressively...

    I don't know what to check. Do you have any hints in order to debug these two issues ?



  • Hello,

    I have tried with the version 5.6.2 of Qt, but the behaviour is the same. Anyone can help me ?

    Thanks a lot.

    Best regards,

    Simon Brizard


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Looks like there's something low level going on. I'd recommend bringing that question to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.