Connection Reset during PUT

691 views
Skip to first unread message

al...@thesimplersolution.co.uk

unread,
Sep 24, 2013, 6:05:37 AM9/24/13
to sardi...@googlegroups.com
Hi all,

I've had a strange problem using Sardine whilst connected to SharePoint.

Firstly, some background.  I've developed a simple Java app that transfers files between 2 WebDav servers.  This works great on OSX and Apache with WebDav... but fails when ran on Windows or on AIX servers connecting to a SharePoint WebDav.

It always fails when doing the PUT command to the destination server.  Many other commands work fine, so I can list, get, make directories, etc.

The error I get is java.net.SocketException: Connection reset

Stack trace is as follows:

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:179)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
at org.apache.http.impl.io.SocketInputBuffer.isDataAvailable(SocketInputBuffer.java:101)
at org.apache.http.impl.AbstractHttpClientConnection.isResponseAvailable(AbstractHttpClientConnection.java:246)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.isResponseAvailable(ManagedClientConnectionImpl.java:180)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:716)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:521)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1138)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1076)
at com.github.sardine.impl.SardineImpl.execute(SardineImpl.java:807)
at com.github.sardine.impl.SardineImpl.put(SardineImpl.java:738)
at com.github.sardine.impl.SardineImpl.put(SardineImpl.java:714)
at com.github.sardine.impl.SardineImpl.put(SardineImpl.java:684)
at com.github.sardine.impl.SardineImpl.put(SardineImpl.java:676)
at com.github.sardine.impl.SardineImpl.put(SardineImpl.java:670)
at WebDavWrapper.putFile(WebDavWrapper.java:36)

Any ideas why this could occur?  Are there any questions I could ask the network team about the connection between the Windows / AIX servers and the SharePoint server?

Thanks,


Alan

al...@thesimplersolution.co.uk

unread,
Sep 24, 2013, 6:17:51 AM9/24/13
to sardi...@googlegroups.com
I should add... I am performing the sardine.put() using the FileInputStream technique, e.g:

        FileInputStream putStream = new FileInputStream(new File(localFilePath));

        sardine.put(destinationWebDavUrl, putStream);

Also... I've noticed that the connection reset appears to occur at the end of the put().  When I upload a small file it resets immediately, if I put up a very large file it will throw the exception after a delay.

Hope this helps,


Alan

al...@thesimplersolution.co.uk

unread,
Sep 24, 2013, 8:49:54 AM9/24/13
to sardi...@googlegroups.com
Hi everyone,

I'd still be interested in know why this was occuring... however I've found that it works correctly when I don't use streams, but instead read the file into a byte array first.  So... this code now works without error:

byte[] data = FileUtils.readFileToByteArray(new File(localFilePath));
sardine.put(destinationWebDavUrl, data);

Could the stream be having problems reading, or perhaps it is sending the wrong content-length up with the stream?

Any ideas folks?


Alan

Jon Stevens

unread,
Sep 24, 2013, 10:16:23 AM9/24/13
to sardi...@googlegroups.com
Turn on verbose http logging. You probably want wire level logging. See if there is anything interesting in there.


jon



--
You received this message because you are subscribed to the Google Groups "sardine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sardine-dav...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alan Graham

unread,
Sep 24, 2013, 10:24:37 AM9/24/13
to sardi...@googlegroups.com
Thanks jon I will look into that.  Obviously reading the file contents into memory is not optimal.


--
You received this message because you are subscribed to a topic in the Google Groups "sardine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sardine-dav/LxJtnwIDiV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sardine-dav...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Alan Graham

The Simpler Solution Ltd

e: al...@thesimplersolution.co.uk
w: http://www.thesimplersolution.co.uk
p: +44 (0) 7766 132 158

Unless by prior written agreement, all work adheres to 
our standard Terms & Conditions. 

Joanne Kelly

unread,
Dec 1, 2013, 12:37:34 PM12/1/13
to sardi...@googlegroups.com
Did you get this resolved?  I am having a different problem with the Put (it works okay as long as I do a List first).  I am using a Stream and need to use a Stream because of the File sizes we have.


Alan Graham

unread,
Dec 1, 2013, 2:40:21 PM12/1/13
to sardi...@googlegroups.com
I never got it resolved.  We decided to just keep using a byte[] array.

Are you using any form of authentication on your WebDAV server - it seems to make a difference.


Alan


On Sun, Dec 1, 2013 at 5:37 PM, Joanne Kelly <jkell...@gmail.com> wrote:
Did you get this resolved?  I am having a different problem with the Put (it works okay as long as I do a List first).  I am using a Stream and need to use a Stream because of the File sizes we have.


--
You received this message because you are subscribed to a topic in the Google Groups "sardine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sardine-dav/LxJtnwIDiV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sardine-dav...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Joanne Kelly

unread,
Dec 1, 2013, 2:50:47 PM12/1/13
to sardi...@googlegroups.com
We are using authentication.

It is odd because all works well if we do a list before the put -- we can use the Stream on the put.  However, if I remove the list, I get a ClientProtocolException with the put.  It seems that the list is initializing something that the put needs.

Thanks for letting me know.

Alan Graham

unread,
Dec 1, 2013, 2:53:19 PM12/1/13
to sardi...@googlegroups.com
I will try to do a List before Put next week, at least it could be helpful to others who come across this.


--
You received this message because you are subscribed to a topic in the Google Groups "sardine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sardine-dav/LxJtnwIDiV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sardine-dav...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Joanne Kelly

unread,
Dec 2, 2013, 2:04:03 PM12/2/13
to sardi...@googlegroups.com
See my response to "Sardine put getting ClientProtocolException if not doing list first".  It gives an explanation for the problem.  You can also do an Exists to get around the problem.


Joanne Kelly

unread,
Dec 3, 2013, 11:08:06 AM12/3/13
to sardi...@googlegroups.com
Alan -- our problem is completely resolved.  See my response to "Sardine put getting ClientProtocolException if not doing list first".  Perhaps the 2 things we had to do will also resolve your problem.

Sasan Yavari

unread,
Feb 3, 2014, 2:57:32 AM2/3/14
to sardi...@googlegroups.com
Hi friends,

I enabled the PreemptiveAuthentication for my host but I have same problem.

I get Connection Reset during PUT and also I have another problem, it takes too long to get Connection Reset during PUT request. I can see server logs and after at least 5 minutes of stopping data transfer, Connection Reset happening.

I have 10000ms connection timeout and 20000ms socket timeout but program don't show respect to my timeout settings.
Is there any solution for this problems?
Reply all
Reply to author
Forward
0 new messages