FastDFS 服务启动后第一次上传附件报错:java.net.SocketException: Software caused connection abort: socket write error
- 第二次上传就ok,方法是没问题的,那么就是初始化相关的问题;
- 修改配置:有网友提到:
(如果客户端服务启动,成功链接到dfs服务器,如果在network_timeout时间内,dfs服务没有接收到任何请求信息,会把这个客户端踢掉!)
connect_timeout=300 network_timeout=600 tracker_server= (ip) use_connection_pool = false connection_pool_max_idle_time = 3600 load_fdfs_parameters_from_tracker=false use_storage_id = false storage_ids_filename = storage_ids.conf http.tracker_server_port=11111
-
这就需要每次启动后给dfs服务发送一些消息;对dfs又研究了一波,发现
fastdfs-client-java
包的ProtoCommon.java
已经提供了一个发送信息的方法,如下:public static boolean activeTest(Socket sock)
- 初始化代码:核心代码:
java ProtoCommon.activeTest(TRACKERSERVER.getSocket());
private static TrackerClient TRACKERCLIENT; private static TrackerServer TRACKERSERVER; private static StorageServer STORAGESERVER; private static StorageClient STORAGECLIENT; static { try { String classPath = new File(FileManager.class.getResource("/").getFile()).getCanonicalPath(); String fdfsClientConfigFilePath = classPath + File.separator+ FastDfsFileManagerConfig.fdfs_client_conf; ClientGlobal.init(fdfsClientConfigFilePath); TRACKERCLIENT = new TrackerClient(); TRACKERSERVER = TRACKERCLIENT.getConnection(); ProtoCommon.activeTest(TRACKERSERVER.getSocket()); } catch (Exception e) { e.printStackTrace(); } }
- 初始化代码:核心代码:
-
然后重启再测试上传