apache ftpClient 多網絡卡上傳檔案超時解決。
在伺服器中有多個網絡卡,預設的路由不是當前的ftp伺服器走的路由。
修改ftpclinent.java 中的程式碼實現。
protected Socket _openDataConnection_(String command, String arg) throws IOException { if (__dataConnectionMode != ACTIVE_LOCAL_DATA_CONNECTION_MODE && __dataConnectionMode != PASSIVE_LOCAL_DATA_CONNECTION_MODE) { return null; } final boolean isInet6Address = getRemoteAddress() instanceof Inet6Address; Socket socket; if (__dataConnectionMode == ACTIVE_LOCAL_DATA_CONNECTION_MODE) { // if no activePortRange was set (correctly) -> getActivePort() = 0 // -> new ServerSocket(0) -> bind to any free local port ServerSocket server = _serverSocketFactory_.createServerSocket(getActivePort(), 1, getHostAddress()); try { // Try EPRT only if remote server is over IPv6, if not use PORT, // because EPRT has no advantage over PORT on IPv4. // It could even have the disadvantage, // that EPRT will make the data connection fail, because // today's intelligent NAT Firewalls are able to // substitute IP addresses in the PORT command, // but might not be able to recognize the EPRT command. if (isInet6Address) { if (!FTPReply.isPositiveCompletion(eprt(getReportHostAddress(), server.getLocalPort()))) { return null; } } else { if (!FTPReply.isPositiveCompletion(port(getReportHostAddress(), server.getLocalPort()))) { return null; } } if ((__restartOffset > 0) && !restart(__restartOffset)) { return null; } if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) { return null; } // For now, let's just use the data timeout value for waiting for // the data connection. It may be desirable to let this be a // separately configurable value. In any case, we really want // to allow preventing the accept from blocking indefinitely. if (__dataTimeout >= 0) { server.setSoTimeout(__dataTimeout); } socket = server.accept(); } finally { server.close(); } } else { // We must be in PASSIVE_LOCAL_DATA_CONNECTION_MODE // Try EPSV command first on IPv6 - and IPv4 if enabled. // When using IPv4 with NAT it has the advantage // to work with more rare configurations. // E.g. if FTP server has a static PASV address (external network) // and the client is coming from another internal network. // In that case the data connection after PASV command would fail, // while EPSV would make the client succeed by taking just the port. boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address; if (attemptEPSV && epsv() == FTPReply.ENTERING_EPSV_MODE) { _parseExtendedPassiveModeReply(_replyLines.get(0)); } else { if (isInet6Address) { return null; // Must use EPSV for IPV6 } // If EPSV failed on IPV4, revert to PASV if (pasv() != FTPReply.ENTERING_PASSIVE_MODE) { return null; } _parsePassiveModeReply(_replyLines.get(0)); } socket = _socketFactory_.createSocket(); // 新增加bind 源地址操作。 if (localAddr != null) { System.out.println(">>>>>>>>>>>>>>>>>>FTPClient localAddr"+localAddr); socket.bind(new InetSocketAddress(localAddr, localPort)); }
socket.connect(new InetSocketAddress(__passiveHost, __passivePort), connectTimeout); if ((__restartOffset > 0) && !restart(__restartOffset)) { socket.close(); return null; } if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) { socket.close(); return null; } } if (__remoteVerificationEnabled && !verifyRemote(socket)) { socket.close(); throw new IOException("Host attempting data connection " + socket.getInetAddress().getHostAddress() + " is not same as server " + getRemoteAddress().getHostAddress()); } if (__dataTimeout >= 0) { socket.setSoTimeout(__dataTimeout); } return socket; }
相關推薦
apache ftpClient 多網絡卡上傳檔案超時解決。
在伺服器中有多個網絡卡,預設的路由不是當前的ftp伺服器走的路由。 修改ftpclinent.java 中的程式碼實現。 protected Socket _openDataConnection_(String comm
dubbo多網絡卡時,服務提供者的錯誤IP註冊到註冊中心導致消費端連線不上
使用了虛擬機器之後,啟動了dubbo服務提供者應用,又連了正式環境的註冊中心; 一旦dubbo獲取的ip錯誤後, 這種情況即使提供者服務停掉,目前dubbo沒有能力清除這類錯誤的提供者; (需要修改原始碼測試,需要客戶端重新更細包,因為清除動作client端,我司就是這麼幹的) 規
在linux下面虛擬多塊網絡卡,在一塊物理網絡卡上配置多個IP地址
1.首先,我們來配置多塊虛擬網絡卡 將一個物理網絡卡,虛擬多個網絡卡使用方法,在這塊網絡卡上配置同一個段的ip地址: 比如將em2這塊物理網絡卡(該網絡卡的ip地址192.168.100.10/24)配置成多塊網絡卡的命令: ifconfig em2:1 192.16
【shell】海思3536 多網絡卡繫結聚合——bond技術
0.原理說明 目前網絡卡繫結mode共有七種(0~6)bond0、bond1、bond2、bond3、bond4、bond5、bond6 常用的有三種: mode=0:平衡負載模式,有自動備援,但需要”Switch”支援及設定。 mode=1:自動備援模式,其中一條線若斷線,其他線路
Eureka的自我保護模式、多網絡卡環境下的IP選擇和健康檢查
Eureka的自我保護模式 禁用自我保護模式: eureka.server.enable-self-preservation = false 多網絡卡環境下的IP選擇 對於多網絡卡的伺服器,各個微服務註冊到Eureka Server上的IP要如何指定呢? 指定IP在某些場合下
spring cloud EurekaClient 多網絡卡 ip 配置 和 原始碼分析
1、前言 對於spring cloud,各個服務例項需要註冊到Eureka註冊中心。 一般會配置ip註冊,即eureka.instance.prefer-ip-address=true。 但是,如果服務例項所在的環境存在多個網絡卡,經常會出現註冊過去的ip不是我們想要的ip。
c# 多網絡卡 由【網路介面卡名】獲取網絡卡資訊,IP
c# 多網絡卡 由【網路介面卡名】獲取網絡卡資訊,IP 多網絡卡電腦中,網路介面卡的名字 多樣化! 專案中需要,根據網路介面卡 名字 獲取 單個網絡卡的IP: using System.Net.NetworkInformation;
Linux中高階網路配置-team方式多網絡卡繫結
team簡介 在redhat7.0以上版本,配置多網絡卡繫結時,專門提供了team工具來實現多網絡卡的繫結。 team :也是鏈路聚合 最多支援8塊網絡卡,不需要手動載入相應核心模組 支援模式: broadcast 廣播容錯 roundrobin 輪詢
多網絡卡Ubuntu伺服器安裝Kubernetes
多網絡卡伺服器安裝Kubernetes如何指定叢集選用的IP地址呢? 指定--apiserver-advertise-address引數即可。如下: sudo kubeadm init --kubernetes-version=v1.12.2 --apiserver-advertise-ad
Ubuntu 18.04 設定多網絡卡多埠聚合
多網絡卡聚合把多個網路埠繫結到一個IP地址,可以提高網路總頻寬和容錯能力。 Ubuntu 18.04使用了netplan來管理網路,跟以前版本差別很大。以前版本修改/etc/network/interfaces的方法不再管用,設定多網絡卡聚合的方式也有點不一樣了,不過實際用起來比以前還
雲伺服器多網絡卡配置實踐
環境概述: 系統環境:標準型S2、1核2G、1Mbps、Centos7.4 64位、騰訊雲、北京一區、VPC(私有網路) 遠端連線工具:xshell5 目標: 為伺服器配置 2個網絡卡,每個網絡卡配置2個內網ip、2個外網ip,共計4個外網ip、4
CentOS下多網絡卡繫結bond/多網絡卡聚合
網絡卡bond我直接理解成網絡卡聚合了,就是把多張網絡卡虛擬成1張網絡卡,出口時,這張網絡卡無論哪個斷線都不影響網路,入口時,需要結合交換機的埠聚合功能實現和網絡卡配置的bond模式進行負載均衡。bond需要在核心Kernels 2.4.12及以上才能使用,因為需要使用bonding模組。 bond模式:
02 Linux 多網絡卡繫結
Linux 多網絡卡繫結 網絡卡繫結mode共有七種(0~6) bond0、bond1、bond2、bond3、bond4、bond5、bond6 常用的有三種 mode=0:平衡負載模式,有自動備援,但需要”Switch”支援及設定。 mode=1:自
多網絡卡繫結:active-backup - 主備模式
網絡卡繫結模式:active-backup - 主備模式 一個網絡卡處於活躍狀態,另一個處於備份狀態,所有流量都在主鏈路上處理,當活躍網絡卡down掉時,啟用備份網絡卡。 系統:這裡以Centos7為例(Centos6配置引數和7不一樣) 這裡將em1和em2繫結到bond0上,
Linux--多網絡卡的7種Bond模式
網絡卡bond是通過把多張網絡卡繫結為一個邏輯網絡卡,實現本地網絡卡的冗餘,頻寬擴容和負載均衡。在應用部署中是一種常用的技術,我們公司基本所有的專案相關伺服器都做了bond,這裡總結整理,以便待查。 bond模式: Mode=0(balance-rr) 表示負載分擔round-ro
centos6多網絡卡bonding
繫結bond步驟: 1.進入/etc/sysconfig/network-scripts/目錄; 2.建立(或複製重新命名)bond0配置檔案: #cp ifcfg-eth1 ifcfg-bond0 3.修改ifcfg-bond0: #vi if
bond多網絡卡繫結
bond多網絡卡 | &
多網絡卡繫結bonding
linux下多網絡卡繫結bonding Linux bonding 驅動提供了一個將多個物理網路埠捆綁為單個邏輯網路埠的方法,用於網路負載均衡、冗餘和提升網路的效能,比如對於備份伺服器,需要在一個晚上備份幾個T的資料,如果使用單個的千兆網口將會是很嚴重的瓶頸。其它的應用,比如ftp伺服器,高負載
Linux的多網絡卡繫結
載入bonding模組,options裡的一些引數的含義: miimon 監視網路連結的頻度,單位是毫秒。 max_bonds 配置的bond口個數 mode bond模式,在一般的實際應用中,0和1用的比較多。 bond模式:常用的有三種 mode=0:平衡負載模式,有自動備援,但需要”Swi
Linux 配置ip 子介面 多網絡卡繫結
linux系統配置ip地址,圖形化介面略過,這裡只介紹文字行。做以下設定注意是否有此許可權檢視當前路由及閘道器資訊: [[email protected] ~]# netstat -r Kernel IP routing table Destination Gateway G