Microsoft Graph Api : Socket exception: Socket is closed

Karanvir Sidhu 1 Reputation point
2021-02-02T04:19:50.467+00:00

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
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,805 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2021-02-02T20:22:10.327+00:00

    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