Facing java.net.SocketException: Connection reset while making a REST get request call to sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 06:52 AM
Hi Experts,
I am querying service now accounts using REST API get request call to sys_user table of service now and facing below error -- j
java.net.SocketException: Connection reset
Its happening at the time of parsing the response basically and not sure what is the possible cause for this and how can i debug this further.I suspected this might be due to connection opening/closing handling but we are using only one connection throughout my java file and closing at the end when all records are processed successfully.
Got below logs for reference which all are suggesting to lower the sysparam limit value.But i tried with 500 sysparam limit value and still got the socketException.
GET request
/api/now/v1/table/sys_user?sysparm_query=user_nameISEMPTY^NQuser_name!=admin^user_name!=servicenow&sysparm_offset=250000&api=api&sysparm_display_value=true&sysparm_limit=5000 node: xyz session: session id FROM LOGS: 2019-02-20 20:59:19 (328) API_INT-thread-3 ADF2D1A6DBBFA34492C25F5E5E961947 WARNING *** WARNING *** SizeAwareServletOutputStream@10774756: Large amount of data has been streamed: 1,048,823 bytes 2019-02-20 20:59:38 (905) API_INT-thread-3 ADF2D1A6DBBFA34492C25F5E5E961947 WARNING *** WARNING *** #8641361 [REST API] RESTAPIProcessor : Handling exception Streaming error 2019-02-20 20:59:38 (906) API_INT-thread-3 ADF2D1A6DBBFA34492C25F5E5E961947 WARNING *** WARNING *** #8641361 [REST API] RESTAPIProcessor : Unknown exception RuntimeException:Streaming errorDetail: Streaming error 2019-02-20 20:59:38 (907) API_INT-thread-3 ADF2D1A6DBBFA34492C25F5E5E961947 WARNING *** WARNING *** #8641361 [REST API] ResponseSerializer : Streaming exception (won't rethrow): java.net.SocketException: Broken pipe (Write failed)
Has anyone ever has faced this issue.Any help would be greatly appreciated.
Thanks
Vivek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 06:57 AM
I would say rather than getting all the data at a time, use getKeys methods to get sys_id's matching your query. And then traverse through the sys_id's to get data for one user account at a time.
The above issue seems might relate to response being very big
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 01:02 AM
Hi Mateen,
Thanks for the reply.
Actually I am hitting servicenow api get rquest for bulk users(sysparam=5000) which is working perfectly fine through postman rest client but in my application it is throwing the response transformation failed exception(I/O exception) caused via socket exception-connection reset.I am wondering how the connection is getting closed either by my application or servicenow when i am not closing any connection in between.I have only one connection which is getting closed after processing all the data from servicenow at the end.
Thanks
Vivek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 03:26 AM
Kindly, you have any updates about this issue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2021 09:08 PM
Connection reset simply means that a TCP RST was received. This happens when your peer receives data that it can't process, and there can be various reasons for that. A reset packet is simply one with no payload and with the RST bit set in the TCP header flags. The simplest is when you close the java socket, and then write more data on the output stream. By closing the socket, you told your peer that you are done talking, and it can forget about your connection. When you send more data on that stream anyway, the peer rejects it with an RST to let you know it isn't listening.
There are several possible causes.
- The other end has deliberately reset the connection.
- Writing to a connection that the other end has already closed
- Closing a socket when there is unread data in the socket receive buffer.
- In Windows, 'software caused connection abort', which is not the same as 'connection reset', is caused by network problems sending from your end.