1

I am working on an electron app with Angular2 for frontend. When user reaches the home page, angular starts a http.get service which initiates a hardware device which waits for user input in form of RFID cards. When user response is triggered then express returns the GET call with data. User event may occur from a few seconds to few hours. It works fine if user responds quickly but after a couple of minutes Angular doesn't show the response.

I am sorry for the unclear question details. I don't know what code to add. Any help would be highly appreciated.

Harshit
  • 45
  • 2
  • 7
  • Do you control the express part too? If so, you could change it to return 202 Accepted immediately, along with a link to poll for completion and data. Then you don't have to have a long running request that electron might give up on. – jonrsharpe Sep 10 '17 at 08:11
  • @jonrsharpe Thanks. I was under the impression that express would do that immediately when the request is received. I will try that. And also study express properly. – Harshit Sep 10 '17 at 08:25
  • Unless you say otherwise it will attempt to do everything then return 200 OK. This will mean the request timing out if the client has had enough of waiting. – jonrsharpe Sep 10 '17 at 08:29
  • I am sorry for asking a dumb question. I am just getting started with web development. I sent status 202. But that is causing the client to stop requesting the server for further response. How would the client know when to ask the server again? – Harshit Sep 10 '17 at 08:35
  • That's what's supposed to happen. As I said above, you return with that response a location where the data will become available, then the client can keep checking the new location, at a frequency of your choosing, until it returns the data. See e.g. https://stackoverflow.com/q/33009721/3001761 – jonrsharpe Sep 10 '17 at 08:55

0 Answers0