c# - Replicate IO Exception Error -
i able reproduce following error:
ioexception: unable read data transport connection: existing connection forcibly closed remote host.
any ideas on how can making web request , causing error occur?
i've tried making web request , unplugging network cable didn't reproduce error, i'm intrigued how can make happen.
the last line produce exception.
the idea is: creating tcp listener (or http listener) , closing connection without sending valid http response.
taskcompletionsource<object> tcs = new taskcompletionsource<object>(); task.run(() => { tcplistener listener = new tcplistener(8080); listener.start(); tcs.trysetresult(null); while (true) { listener.accepttcpclient().close(); } }); await tcs.task; //wait till tcplistener ready webclient wc = new webclient(); var str = await wc.downloadstringtaskasync("http://localhost:8080");
Comments
Post a Comment