c# - FTPWebRequest: The underlying connection was closed: An unexpected error occurred on a receive -
i've got problem when uploading files ftp server. connection works fine on local connection - however, im trying connect public ip address of system (ftp://xx.xxx.xxx.xx). can connect fine on filezilla upload , download files - however, reason not seem work.
this code im using create webrequest:
ftpwebrequest request = (ftpwebrequest)webrequest.create("ftp://xx.xxx.xx.xxx" + uploadpath); request.usebinary = true; request.keepalive = false; request.method = webrequestmethods.ftp.uploadfile;
that runs fine in debug mode, filepaths allowed, etc.. however, code throwing error in section here:
byte[] b = file.readallbytes(tarpath); request.contentlength = b.length; using (stream s = request.getrequeststream()) { s.write(b, 0, b.length); } ftpwebresponse ftpresp = (ftpwebresponse)request.getresponse(); if (ftpresp != null) { debug.writeline(ftpresp.statusdescription); }
any ideas? i've searched through various online posts error , of them in regards httpwebrequest, not ftpwebrequest. if code works on local connection, why acting on global connection?
thanks in advance
edit requested, i've enabled network logging , here output - bare in mind i've changed our public server ip 00x000x00x000 security reasons , not error ! :)
system.net information: 0 : [7120] ftpwebrequest#35287174::.ctor(ftp://00.000.00.000/users/be83dec5d120c42a6b94/119ab9d171cce2528d9a.tar) system.net information: 0 : [7120] ftpwebrequest#35287174::getrequeststream(method=stor.) system.net information: 0 : [7120] current os installation type 'client'. system.net information: 0 : [7120] ras supported: true system.net error: 0 : [7120] can't retrieve proxy settings uri 'ftp://00.000.00.000/users/be83dec5d120c42a6b94/119ab9d171cce2528d9a.tar'. error code: 12180. system.net information: 0 : [7120] ftpcontrolstream#10261382 - created connection 192.168.0.48:15275 00.000.00.000:21. system.net information: 0 : [7120] associating ftpwebrequest#35287174 ftpcontrolstream#10261382 system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [220 (vsftpd 3.0.2)] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [user dev] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [331 please specify password.] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [pass ********] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [230 login successful.] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [opts utf8 on] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [200 in utf8 mode.] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [pwd] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [257 "/home/dev"] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [type i] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [200 switching binary mode.] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [pasv] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [227 entering passive mode (58,104,53,147,24,79).] system.net information: 0 : [7120] ftpcontrolstream#10261382 - sending command [stor users/be83dec5d120c42a6b94/119ab9d171cce2528d9a.tar] system.net information: 0 : [7120] ftpcontrolstream#10261382 - received response [150 ok send data.] system.net information: 0 : [5756] servicepoint#22597652 - closed idle. system.net information: 0 : [7120] ftpwebrequest#35287174::(releasing ftp connection#10261382.) system.net error: 0 : [7120] exception in appdomain#4032828::unhandledexceptionhandler - underlying connection closed: unexpected error occurred on receive.. @ system.net.ftpwebrequest.syncrequestcallback(object obj) @ system.net.ftpwebrequest.requestcallback(object obj) @ system.net.commandstream.dispose(boolean disposing) @ system.io.stream.close() @ system.io.stream.dispose() @ system.net.connectionpool.destroy(pooledstream pooledstream) @ system.net.connectionpool.putconnection(pooledstream pooledstream, object owningobject, int32 creationtimeout, boolean canreuse) @ system.net.ftpwebrequest.finishrequeststage(requeststage stage) @ system.net.ftpwebrequest.syncrequestcallback(object obj) @ system.net.ftpwebrequest.requestcallback(object obj) @ system.net.commandstream.abort(exception e) @ system.net.commandstream.checkcontinuepipeline() @ system.net.ftpwebrequest.datastreamclosed(closeexstate closestate) @ system.net.ftpdatastream.system.net.icloseex.closeex(closeexstate closestate) @ system.net.ftpdatastream.dispose(boolean disposing) @ system.io.stream.close() @ system.io.stream.dispose() @ tcpclient.ftpclass.upload(string tarpath, string uploadpath) in c:\users\adam\desktop\project\workspace\network\safespotservice\safespotclient\safespotclient\ftpclass.cs:line 84 @ safespotclient.service1.checkincycle(string macaddr) in c:\users\adam\desktop\project\workspace\network\safespotservice\safespotclient\safespotclient\service1.cs:line 121 @ safespotclient.service1.callback(object state) in c:\users\adam\desktop\project\workspace\network\safespotservice\safespotclient\safespotclient\service1.cs:line 168 @ system.threading.timerqueuetimer.callcallbackincontext(object state) @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.timerqueuetimer.callcallback() @ system.threading.timerqueuetimer.fire() @ system.threading.timerqueue.firenexttimers() @ system.threading.timerqueue.appdomaintimercallback()
Comments
Post a Comment