LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2019, 08:18 PM   #1
tseesink
LQ Newbie
 
Registered: Sep 2019
Location: QLD, Australia
Distribution: Ubuntu
Posts: 3

Rep: Reputation: Disabled
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;
STDOUT->autoflush();
$|=1;

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.
Thanks,
TomS
 
Old 09-09-2019, 10:31 PM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,492

Rep: Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921
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.

Last edited by berndbausch; 09-09-2019 at 10:35 PM. Reason: added disclaimer
 
Old 09-09-2019, 10:58 PM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,831

Rep: Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294
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?
 
Old 09-09-2019, 11:34 PM   #4
tseesink
LQ Newbie
 
Registered: Sep 2019
Location: QLD, Australia
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
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 www.sendgrid.com 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.
 
Old 09-10-2019, 02:14 AM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,831

Rep: Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294
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?
 
Old 09-10-2019, 02:28 AM   #6
tseesink
LQ Newbie
 
Registered: Sep 2019
Location: QLD, Australia
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.

TomS
 
Old 09-10-2019, 02:36 AM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,831

Rep: Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294Reputation: 1294
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...
 
Old 09-10-2019, 08:48 AM   #8
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: CentOS, MacOS, [Open]SuSE, Raspian, Red Hat, Slackware, Solaris, Tru64
Posts: 1,507

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by scasey View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Control stdin buffering weeny Linux - General 0 10-27-2003 06:17 AM
Regarding buffering with streams karthikvina Programming 0 09-04-2003 02:48 AM
frame buffering problem. GT-GEO Linux - General 3 01-31-2002 04:26 AM
Disable Virtual Frame Buffering? Syncrm Linux - General 2 01-28-2002 11:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration