Reputation: 143
I have a simple Client application (using QWebSocket
) that wants to connect to my server application (i.e. QWebSocketServer
).
When I open a connection to a webSocketServer that is down/unavailable, my webSocket fires a "disconnectd" signal after 30 sec.
This is good as it helps me to understand that the server is down/unavailable so I can retry or warn the user about the problem.
If the link between the client and server fails the same thing happens. i.e. after writing (sendBinaryMessage) to the webSocket causes the disconnected signal to be fired after 30 secs.
I would like to know what are the default timers in QWebSocket
and how I can modify them?
Where can I find such information/documentation? The Qt documentation on webSockets does not mention this behaviour at all! Should I read the code or ...?!
Thanks in advance
Upvotes: 2
Views: 2249
Reputation: 28892
I doubt that any of these timers are part of Qt; these timers exist as part of the underlying operating system's implementation of TCP/IP. A socket waiting for a connection to time out will eventually go bad if the remote end does not respond. Same if a sent data is not acknowledge after a reasonable amount of time.
Qt however does everything asynchronously and makes use of signals and slots to notify you when something has happened. This means that if you want to shorten a timeout the simplest way to do this is using a QTimer
that runs in parallel to you QAbstractSocket
, if the timer times out before the socket signals its response, you can then take appropriate action.
Failing that, there may be some socket options that allow you to set the various timeouts on your TCP Connection to your liking.
Upvotes: 1
Reputation: 4845
From QWebSocket:
This class was modeled after QAbstractSocket.
QAbstractSocket
in turn inherits from QIODevice
.
The documentation of these classes have some information about timeouts. Specifically you can see the default of 30 seconds pop up here and there.
Another place to look at is QObject
's documentation (QWebSocket inherits it). Perhaps by overriding QObject
's timer-related virtual functions you can somehow get in between these mechanisms and perhaps change the timeout.
Sorry to not be of more help.
Upvotes: -1