2

My code is hosted on amazon web service server and I m using Hathway Internet Service Provider (India based ISP). Previously my code was working perfectly with Hathway ISP but from few days back my code is not working as expected. I tried to execute same code from another user of Hathway ISP there also I faced same issue. I thought there was something wrong with my code, after debugging I found everything was perfect, this I came to know when I executed my code with some other ISP. What is happening with Hathway ISP is, it's sending multiple request to server. Browser sending only one request to the server this I checked in browser Network tab but doesn't know what happening in the middle that server getting multiple request. Let me give some overview of my code,

  1. It is written in php
  2. Excel file is being downloaded
  3. Code has huge calculation so it takes 10 to 15 min for excel file to get downloaded

Thanks

  • I'm not sure what the question is, but if your ISP is tampering with your request, you should make sure you use ssl. – jeroen Jun 28 '16 at 07:56
  • @jeroen I have perfect code running with other ISP. Its plain http request. Will try with ssl. Thanks – bhanushalimahesh3 Jun 28 '16 at 08:04
  • attach debug info ? Try to see log – Mohammad Sayeed Jun 28 '16 at 08:04
  • does your server work with keep-alive? But with such a long computational drive, you should really defer it to a background process, poll computation status with ajax, then when ready offer the background link. – Tschallacka Jun 28 '16 at 08:12
  • @MohdSayeed I have manually logged inside every function. The main function which should be called only once is getting called multiple times. Which results in no data received err_empty_response at browser side but in background execution continues till it gets done. Nothing is logged in apache error log because no error has occured – bhanushalimahesh3 Jun 28 '16 at 08:15
  • @MichaelDibbets I have this issue with Hathway ISP only it's working with Other ISP – bhanushalimahesh3 Jun 28 '16 at 08:25
  • You're focussing wrongly. The ISP won't change for you, and if this ISP has this issue, others will have too. You need a more bullet proof approach to your code. see my answer :-) – Tschallacka Jun 28 '16 at 08:32

2 Answers2

1

Looking at your requirements I think there might be issues with the overly long computation, and the ISP is resending requests to test if it's alive, or something along the lines of that.

Ideally in a process like this you'd do something like this:

  1. User clicks process button:
    1.1 Ajax request gets sent to php to calculate excel file.

  2. Ajax request received.
    2.1 generate polling id.
    2.2 exec('php calculateExcel.php $pollingid'); (see this answer)
    2.3 send polling id to user

  3. receive polling id
    3.1 request compilation status every 5 seconds

  4. receive compilation status request
    4.1 poll database/file/whatever by polling idto see how far it is in compiling
    4.2.1. if not done, return percentage complete
    4.3.2. if finished, return download link

  5. receive status answer
    5.1. if not complete, update statusbar
    5.2. if complete, remove status bar, show download link.

That's how I would do it. That way your server can crunch along happily computing the massive excel file, the user doesn't have to fear browser timeouts(some browsers choose to disconnect after 5 minutes), windows network resets/dns renegotiations, wifi disconnects, etc...

As long as the user has his/her polling id, he/she can request the status and/or download the file as long as it's available.

Community
  • 1
  • 1
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
  • In modern browsers He may use web socket also. – Ravinder Payal Jun 28 '16 at 15:31
  • true, but since he's using a 5-15 minute page load i'm going with an easier suggestion for him first. Setting up websockets isn't directly straight forward and easy. – Tschallacka Jun 28 '16 at 15:34
  • Yeah but his question was more challenging than setting up web socket, cheers – Ravinder Payal Jun 28 '16 at 15:46
  • With Web socket he will get access to things like.... How much work done. How much downloaded. How much long it will take to complete the job. – Ravinder Payal Jun 28 '16 at 15:47
  • 1
    You get the same info via ajax. The only advantage is you dont need to re-establish a connection. But you still need to re-establish it when user gets a dc because of shoddy connection. For the purpose of what he needs it ajax calls are sufficient and less resource/data intensive. That way the jub can rune pure solely without dependency on user connection. – Tschallacka Jun 28 '16 at 18:12
  • @MichaelDibbets will give it try if that solves my issue :) – bhanushalimahesh3 Jun 29 '16 at 07:39
0

I would recommend sending data as json in a single request. In php you can defragment it into all the values again. for eg.

xhttp.open("GET", "gotoChatRoomorNot.php?q=[{"+str+"},{"+user1+"},{"+user2"}]", true);

and in php you can follow this to get your data back: How do I extract data from JSON with PHP?

I think you can perform the same kind of behaviour with xml, but i am not aware of xml

Ishan Srivastava
  • 1,129
  • 1
  • 11
  • 29