c# - An unexpected error occurred on a send. EOF or 0 bytes from the transport stream -


i make request https site code:

 webrequest = (httpwebrequest)webrequest.create(new uri(urldestination));             webrequest.method = "post";             webrequest.contenttype = "application/x-www-form-urlencoded";             webrequest.contentlength = bytes.length;              stream writer = webrequest.getrequeststream();             writer.write(bytes, 0, bytes.length);             if (writer != null)             {                 writer.close();             }              response = new streamreader(webrequest.getresponse().getresponsestream()).readtoend(); 

and error:

system.net.webexception: underlying connection closed: unexpected error occurred on send. ---> system.io.ioexception: received unexpected eof or 0 bytes transport stream.    @ system.net.fixedsizereader.readpacket(byte[] buffer, int32 offset, int32 count)    @ system.net.security.sslstate.startreadframe(byte[] buffer, int32 readbytes, asyncprotocolrequest asyncrequest)    @ system.net.security.sslstate.startreceiveblob(byte[] buffer, asyncprotocolrequest asyncrequest)    @ system.net.security.sslstate.checkcompletionbeforenextreceive(protocoltoken message, asyncprotocolrequest asyncrequest)    @ system.net.security.sslstate.startsendblob(byte[] incoming, int32 count, asyncprotocolrequest asyncrequest)    @ system.net.security.sslstate.forceauthentication(boolean receivefirst, byte[] buffer, asyncprotocolrequest asyncrequest)    @ system.net.security.sslstate.processauthentication(lazyasyncresult lazyresult)    @ system.net.tlsstream.callprocessauthentication(object state)    @ system.threading.executioncontext.runtrycode(object userdata)    @ system.runtime.compilerservices.runtimehelpers.executecodewithguaranteedcleanup(trycode code, cleanupcode backoutcode, object userdata)    @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean ignoresyncctx)    @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state)    @ system.net.tlsstream.processauthentication(lazyasyncresult result)    @ system.net.tlsstream.write(byte[] buffer, int32 offset, int32 size)    @ system.net.pooledstream.write(byte[] buffer, int32 offset, int32 size)    @ system.net.connectstream.writeheaders(boolean async)    --- end of inner exception stack trace ---    @ system.net.httpwebrequest.getrequeststream(transportcontext& context)    @ system.net.httpwebrequest.getrequeststream()    @ nop.proxy.send_sync_post.process(namevaluecollection parametersreceived)    @ nop.proxy.includes.page_load(object sender, eventargs e) 

i after checking on web error found solution , didn't worked:

servicepointmanager.securityprotocol = securityprotocoltype.ssl3; 

after taking supplier said encountered error

ssl_do_handshake() failed (ssl: error:1408a0c1:ssl routines:ssl3_get_client_hello:no shared cipher) while ssl handshaking 

i know error part don't know how make request skip error.

the ssl3 statment did solve issue, came across suggestion didn't apply me since have content length statement.

the suggestion remove statement.

my working code follows:

//create webrequest uri jsonuri = new uri(new uri(jirainstanceuri), serviceuri); webrequest restwebrequest = webrequest.create(jsonuri); restwebrequest.method = "get"; restwebrequest.contenttype = "application/json"; //add proxy webrequest proxyserver.bypassarraylist.add(jsonuri); restwebrequest.proxy = proxyserver; //setup authorization string base64credentials = getencodedcredentials(username, password); restwebrequest.headers["authorization"] = "basic " + base64credentials; servicepointmanager.securityprotocol = securityprotocoltype.ssl3; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -