-   Linux - Newbie (
-   -   buffering of perl linux is different from perl windows (

tseesink 09-09-2019 08:18 PM

buffering of perl linux is different from perl windows
Using SMTP on my Windows test server outputs line by line the sending of an email using:
use IO::Handle;
select STDOUT;

The same code on the Linux server buffers the output and causes regularaly the error:
504 Gateway time-out

I am still investigating why but looking for some help too.

berndbausch 09-09-2019 10:31 PM

504 Gateway time-out is the status of an HTTP response. I have strong doubts it has anything to do with the code snippet in your question.

Suggestion: Find HTTP requests in your code and see if one of them might get this timeout. Find out how this is different from the Windows version of your script. Perhaps the Linux box has problems connecting to that web server?

DISCLAIMER: I know close to nothing about Perl.

EDIT: Could it be that I totally misunderstand your question, and your Perl program runs under the web server? The error message appears in a browser rather than then the output of the Perl program? In this case sorry for a misguided answer, but your question doesn't make this clear.

scasey 09-09-2019 10:58 PM

Probably not a perl issue...what is the smtp server on the Linux box? Is it running?
Is it configured correctly? Can you send email from the command line?

tseesink 09-09-2019 11:34 PM

To be more explicit:

I have a test web environment using Windows 7 loaded with Apache 2.2, Perl CGI and MySQL 3.x. The live web environment on Linux runs
also Apache, Perl CGI and MySQL. I have numerous perl programs running and they behave the same on both server environments without any gateway time-out errors.

The perl program for sending out emails from the web server (using as the actual email server) runs without errors on the Windows 7 test server regardless the amount of emails I am sending (between 1 and 700). The program on the Windows machine returns the email address of each email sent line by line so it seems there is no buffering happening on the Windows machine.

Exactly the same program running on the Linux box does not return each email address line by line but it buffers a bunch of email addresses. If the amount of addresses is small (say 30-40) I get a return from the server of all addresses. However when the amount of addresses is large (say 200) I get the 504 gateway time-out error page. However all emails are getting sent but I don't get the feedback from the server that it actually happened.

Lots of reading on this subject and also changing the code of my program has not been successful.

scasey 09-10-2019 02:14 AM

So. You are interacting with a web page and the gateway timeout is displaying in the browser, as berndbausch suggested.
Your perl script is working, the emails are, in fact going out, but there is a problem in the display of that in the browser. Do I have that right now?

If so, I'd look at
  1. the settings of the web servers to see if there are any differences.
  2. the bandwidth/connectivity of the Linux server vs. the Windows server (are they on different networks?).
Have you searched for "504 Gateway time-out"? A DDG search returns several links that discuss possible causes and remedies.
Do the web server logs yield any useful information?

tseesink 09-10-2019 02:28 AM

scasey you're right about the problem of the display of email sending in the browser. Yes the emails are going out. I have to find a way to figure out what happens with the buffering on the live web server because that seems to be the bottleneck.

I have to start checking the differences of both web servers and analyze. The web servers are on different networks. My Windows 7 is a self-contained web server (although it can access the outside world) whereas the live server is somewhere else in the world and hosted by an ISP on a virtual server. This makes it a little more difficult to work with.

I have done a lot of research on the 504 gateway time-out error and have not found a similar situation as I have encountered.

I keep looking and testing.


scasey 09-10-2019 02:36 AM

Perhaps the ISP hosting the VPS has restrictions in place re: connection/sending of bulk emails. I would certainly throttle any customer of mine that was sending 700 emails per click on a web page. That smacks of spam... ;)

rnturn 09-10-2019 08:48 AM


Originally Posted by scasey (Post 6035199)
Perhaps the ISP hosting the VPS has restrictions in place re: connection/sending of bulk emails. I would certainly throttle any customer of mine that was sending 700 emails per click on a web page. That smacks of spam... ;)

Agreed. I was working on a batch process at work whose goal was to send out pricing information to customers---as many as 10k-15k emails depending on the situation that month. The networking team met with us and I let them know we were going to limit the process to only send a small batch (10-20) at a time, sleep a bit, and repeat until the queue was drained. Just so a.) we wouldn't overwhelm the mail servers and b.) the company wouldn't wind up being seen as a spammer.

All times are GMT -5. The time now is 07:32 AM.