c# - Cannot read stream (sslStream) -


i'm trying connect ssl tcp server, works on browser , can receive hardcoded response. on application, exceptions thown when readline function used.

error: system.argumentexception: cannot read stream on system.io.streamreader..ctor(stream stream, encoding encoding, boolean detectencodingfrombyteordermarks, int32 buffersize, boolean leaveopen) on system.io.streamreader..ctor(stream stream) on app_name.program.connection.connect(string serverip, int32 serverport, connectioninfo connectioninfo)

tcpclient = new tcpclient(serverip, serverport); sslstream = new sslstream(tcpclient.getstream(), false, new remotecertificatevalidationcallback(trustallcertificatescallback));  streamreader = new streamreader(sslstream); streamwriter = new streamwriter(sslstream);  string inputline;  while ((inputline = streamreader.readline()) != null) {     parsemessage(streamwriter, serverip, inputline); } 

this line has added below connect function initialize handsake correctly.

sslstream.authenticateasclient(serverip); 

Comments