question

KaranvirSidhu-9604 avatar image
0 Votes"
KaranvirSidhu-9604 asked saldana-msft edited

Microsoft Graph Api : Socket exception: Socket is closed

I’m getting the socket is closed exception quite frequently when trying to call the graph api. Retrying after few seconds it works.
I’m using closeablehttpclient, httpresponse, httpentity.

I guess the problem arise when calling EntityUtils.tobyteArray(entity)

Please advice or suggest.

java.net.SocketException: Socket is closed
at com.ibm.jsse2.as.k(as.java:680)
at com.ibm.jsse2.e.read(e.java:3)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:261)
at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:222)
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:183)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:249)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:169)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:128)
at java.io.FilterInputStream.read(FilterInputStream.java:118)
at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:64)
at org.apache.http.util.EntityUtils.toByteArray(EntityUtils.java:138)

microsoft-graph-sdkmicrosoft-graph-identity
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered KaranvirSidhu-9604 commented

The above error is not coming from Graph API.
- If you can repro the issue with Graph API, then share the Graph API call, requestid/timestamp for analysis.
- Also you can test the same API call in POSTMAN/Graph explorer and see if you can repro the same issue or not

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I’ve tried debugging.. in both positive and negative scenarios I’m getting status 200 but the content length is positive (244) in case of positive scenario and it is -1 in case of negative one.

When it is -1 and then trying EntiryUtils.toByteArray(response entity object) it gives the socket is closed exception.

63500-a75355ed-efd7-42bc-b72b-997c261e69e2.jpeg63591-d00236fd-9405-4dea-bea7-19059a481b02.jpeg


0 Votes 0 ·

To me it is Api response which is responsible.

If the content is not available then the EntityUtils throws socket exception. Entity’s selfClosed is set to true.

Could you confirm this ?

0 Votes 0 ·