Open hakib opened 9 years ago
@hakib Right now it is not possible. Let me add something to allow you to do this. This is what I have in mind:
var url = 'ws://example';
var mockServer = MockServer(url, {
connection_delay: 10000 // 10 seconds
});
var mockSocket = new MockSocket(url);
setTimeout(function() {
if (mockSocket.readyState === MockSocket.CONNECTING) {
// the connection is still pending so we tell the user that the connection is taking longer
// than expected.
mockSocket.close();
}
}, 3000); // check after 3 seconds
Would this work for you?
Thanks @thoov. This looks just about right. How would you suggest setting timeout for send
?
@thoov Is this solution present now? can't seem to make it work
Any news on this?
Is it possible to delay a message by X ms ? specifically the connect message in my case.
I'm trying to test timeouts in some RPC implementation using web sockets. The specific scenario i'm trying to test is the app opening a websocket connection, hitting some internal timeout, notifying the user and setting state to disconnected, then the ws onconnect is invoked in wich case i'm just closing the connection. I have similar scenarios with send as well.
I've seen that you use some "timing hacks" (as you call them) to delay messages (currently set to 4ms). Is it possible to use that some how for my use case?
Thanks.