javascript - WebSocketException: "I/O operation has been aborted" -


trying implement basic websockets channel javscript client , asp.net server. client code goes:

function connect() {     var ws = new websocket("ws://" + window.location.host + "/callback.aspx");     ws.onmessage = function (a) { alert("message"); };     ws.onopen = function (a) { alert("open"); };     ws.onerror = function (a) { alert("error"); }; } 

callback.aspx basic asp.net web page, , goes:

protected void page_load(object sender, eventargs e) {     if (httpcontext.current.iswebsocketrequest)     {         httpcontext.current.acceptwebsocketrequest(socketproc);     } }  private static async task socketproc(aspnetwebsocketcontext a) {     try     {         arraysegment<byte> buffer = new arraysegment<byte>(new byte[1024]);         while (true)         {             websocketreceiveresult res = await a.websocket.receiveasync(buffer, cancellationtoken.none);             if (a.websocket.state != websocketstate.open)                 return;         }     }     catch (exception exc)     {         debug.writeline(exc);     } } 

when try connect client, page_load invoked, socketproc invoked, receiveasync throws following exception:

system.net.websockets.websocketexception (0x800703e3): i/o operation has been aborted because of either thread exit or application request @ system.web.websockets.websocketpipe.<>c__displayclass9_0.<readfragmentasync>b__0(int32 hrerror, int32 cbio, boolean futf8encoded, boolean ffinalfragment, boolean fclose) --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ system.web.websockets.aspnetwebsocket.<dowork>d__45`1.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ system.web.websockets.aspnetwebsocket.<>c__displayclass36_0.<<receiveasyncimpl>b__0>d.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ system.runtime.compilerservices.taskawaiter`1.getresult() @ cleanproxy.callback.<socketproc>d__2.movenext() in c:\dev\cleanmodel\cleanproxy\callback.aspx.cs:line 37 

on client, onopen fires, onerror.

if catch exception around receiveasync, websocket object comes out of closed.

what missing here? testing on windows server 2016, both in iis express , iis proper.

edit: i've been testing built-in ie, i've tried chrome , got different error. time, there's no exception, receiveasync returns object messagetype=close, closestatus=protocolerror. on client, there's error in chrome console:

websocket connection 'ws://localhost:53329/callback.aspx' failed: invalid frame header 

edit2: somehow worked http handler instead of aspx page. freaky. there's no requirement use classic asp.net, this'll now, issue remain unsolved.


Comments

Popular posts from this blog

Formatting string according to pattern without regex in php -

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -