2

I am writing a file synchronization client (in Java 1.6) that uses Sardine:

https://code.google.com/p/sardine/

When Sardine loses connection to the server (ie. network outage or change from LAN to WiFi), I am unable to reconnect until I completely stop the client and start it back up again.

I've tried the following:

  • spamming the connection
  • re-creating the Sardine object dynamically
  • re-packaging Sardine source code with latest Apache HTTP libs

As far as I can tell the actual networking takes place within AbstractHttpClient, but I am not sure what to try next.

Any suggestions on how I can make this thing re-connect dynamically regardless of the reason?

4

1 回答 1

0

您需要关闭沙丁鱼对象并创建另一个对象,例如:

Sardine sardine = SardineFactory.begin();

sardine.createDirectory(url);

if (sardine != null) {
    sardine.shutdown();
}

sardine = SardineFactory.begin();

// use again
于 2018-08-22T16:56:12.937 回答