There is already one outstanding 'ReceiveAsync' call for this WebSocket instance

trade_then


I was trying to refactor .net client. and porting it to .net core.
I keep getting this error once in a while. thou it is recovered efficiently via reconnect. but still i would like to
investigate.

Error:-
There is already one outstanding 'ReceiveAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.

Did you experience this at your end while making this Kiteconnect for dotnet.

I searched on google but couldn`t get satisfactory answer. may be this has something to do with .net core implementation of
Websocket.

Now i am not very proficient in web technologies. so please excuse me for what i am about to submit.
would it be fair to say that this is a blocking call. at OnData such that all subscribed ticks are to be
  • deserialised
  • sent to subscribers of event
and then call returns for next websocket Callback


Althou i have removed it from here, websocket message
  • is being stored in a non-blocking buffer right here
  • from where it is deserialised
  • propagated further to event subscribers.
all the while callback keeps RecieveAsyncing.

could that be the reason for above error sometimes. because i am not blocking for anything at-all. but that still doesn`t make sense because all RecieveAsync call are serial calls, not from multiple sources.

if this question is beyond the scope of this forum then dont sweat on it. I was just curious.


Thanks
Regards




  • tonystark
    Although the calls to WebSocket class are async I'm making them kind of blocking inside the callback with ".Result" call. There will be only one ReceiveAsync running at a time.

    Line 128 kicks of this loop. While loop at line 107 fetches the data in a blocking fashion. Once it is done OnData sends it back to the even callback. And at line 117 it restarts the process just like line 128.

    Above error message happens when that async call is not waited and it immediately goes to next ReceiveAsync call.
  • trade_then
    Hello @tonystark
    Nice to hear from you after long.
    Yes i can see how you are making a blocking call via .Result at line. while only in the while.

    I understand all what you mentioned, but it would take time for me to figure out where i am
    sliping the ReceiveAsync call. for that error to happen. it isnt that obvious.

    Thanks
    Regards
  • tonystark
    Yeah. I had started working on migrating library to .Net standard so that it can be used both in .Net Core and Framework projects. But I haven't reached to WebSocket part yet. Got busy with some other work. Meanwhile if you manage to fix this issue let me know your findings.
Sign In or Register to comment.