Get Positions API exception

I have been encountering below exception frequently when “getPositions” API is called

@shanmu / @Pradeep_Jaiswar please help look into this

com.upstox.ApiException: java.io.IOException: unexpected end of stream on com.squareup.okhttp.Address@ae1d91de
at com.upstox.ApiClient.execute(ApiClient.java:845)
at io.swagger.client.api.PortfolioApi.getPositionsWithHttpInfo(PortfolioApi.java:409)
at io.swagger.client.api.PortfolioApi.getPositions(PortfolioApi.java:395)
at com.broker.upstox.Upstox.getAllCurrentPositions(Upstox.java:481)
at com.bots.NseFutBot.invoke(NseFutBot.java:95)
at com.MainController.createAndInvokeBot(MainController.java:255)
at com.MainController.lambda$invokeBotsForEachProfile$3(MainController.java:219)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.io.IOException: unexpected end of stream on com.squareup.okhttp.Address@ae1d91de
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:201)
at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:722)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at com.upstox.ApiClient.execute(ApiClient.java:841)
… 12 more
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:335)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:106)
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
… 22 more

The issue you’re experiencing is usually a sign of a problem with the network connection. Could you verify if the curl command to get the position operates correctly in your environment?

For example code, you may visit this link: Get Positions | Upstox Developer API.