I have been using neography gem for my rails project and sometimes I end up getting the following error:
<Excon::Error::Socket: end of file reached (EOFError)> #error inspect
Could someone help me troubleshooting this error? Also I am not able to reproduce this error on my demand.
Thanks
That sort of error usually results from connection timeouts from the server you are interacting with. Excon tries to reuse connections, where possible (hence the name, referring to EXtended CONnections), which is generally preferred. Unfortunately it can sometime lead to issues like this.
The lack of reproducibility also sounds like it may be related to timeouts, in particular servers sometimes timeout on inactivity rather than pure clock time (in which case it may only occur when idle.
There are a couple possible approaches to fixing this, though probably they might fit better in neography gem than in your code (and they depend on the context of the particular requests).
The first and best option is only really available if the particular requests are idempotent, and it would be to use the
:idempotent => true
option for the request. Idempotent is there because networks are inherently less than perfect, so it allows a failed request to simply retry automatically in most cases.A less optimal, but more universal answer would be to create a new connection for each request. This should work for any request (idempotent or not), but uses up more connections (which may not matter to you anyway) and is less performant (due to the cost of establishing connections and particularly if https handshakes are required).
Hope that helps paint a clearer picture, I'm not personally familiar with neography, but I'm very familiar with excon, so I think this should be fairly accurate.