RejectedSoftware Forums

Sign up

Assertion in net.d while using websockets

In my application I need to open many websockets(around 300).
Before there was a bug in vibe which was causing me to use child processes because vibe couldn't handle multiple websocket from same process before
(https://github.com/vibe-d/vibe.d/issues/2169).

Now the bug is resolved so I wanted simplify my work flow. I open ~300 websocket and put in list. Than in a for loop I read from them if there is data.

But now I begin to receive an assertion I have no idea why. I tried debugging but couldn't progressed.

Can somebody provide some hint why this can happen ?

core.exception.AssertError@../../../.dub/packages/vibe-core-1.7.0/vibe-core/source/vibe/core/net.d(616): Assertion failure
----------------
??:? _d_assertp [0xb22eb1]
../../../.dub/packages/vibe-core-1.7.0/vibe-core/source/vibe/core/net.d:616 @safe vibe.core.net.WaitForDataStatus vibe.core.net.TCPConnection.waitForDataEx(core.time.Duration) [0xa81ece]
../../../.dub/packages/vibe-core-1.7.0/vibe-core/source/vibe/core/net.d:561 @property @safe ulong vibe.core.net.TCPConnection.leastSize() [0xa81c2a]
../../../.dub/packages/vibe-core-1.7.0/vibe-core/source/vibe/internal/interfaceproxy.d-mixin-302:302 @property @safe ulong vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy.ProxyImpl!(vibe.core.net.TCPConnection).ProxyImpl.__mixin8.__mixin3.__mixin2.leastSize(void[]) [0x99e663]
../../../.dub/packages/vibe-core-1.7.0/vibe-core/source/vibe/internal/interfaceproxy.d-mixin-191:191 @property @safe ulong vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy.__mixin22.__mixin3.__mixin2.leastSize() [0x97515b]
../../../.dub/packages/vibe-d-0.8.6/vibe-d/tls/vibe/stream/openssl.d:1306 onBioRead [0xa4d588]
??:? BIO_read [0x7fa9be977bdb]
Program exited with code -6

Kadir Erdem Demir

Re: Assertion in net.d while using websockets

I realized that if I comment out all the code below I don't recieve that crush anymore.

if ( webSocket.connected && webSocket.dataAvailableForRead() )
{
    allData = webSocket.receiveText();
}


But if I only comment out

//allData = webSocket.receiveText();

It is still crushes .

It also does not crush if I use webSocket.waitForData(1.msecs) like:

if ( webSocket.waitForData(1.msecs) && webSocket.dataAvailableForRead() )
{
    allData = webSocket.receiveText();
}


But I don't want to keep my app block even for 1.msecs because I have 300 of this sockets.

Is there a better alternative for waitForData?

Kadir Erdem Demir