Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP fwrite() Function #235

Open
Sh4d0wless opened this issue Nov 6, 2024 · 12 comments
Open

PHP fwrite() Function #235

Sh4d0wless opened this issue Nov 6, 2024 · 12 comments

Comments

@Sh4d0wless
Copy link

hello
few days ago i transfered my web from VPS to shared hosting(with cpanel)
on VPS everything was perfect, works well without any erros
now im geting this error while cron runs

Notice:  fwrite(): send of 11 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1368
Notice:  fwrite(): send of 11 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1368
Notice:  ob_flush(): failed to flush buffer. No buffer to flush in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 51

[06-Nov-2024 16:25:02 UTC] PHP Notice:  fwrite(): send of 25 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1156
[06-Nov-2024 16:25:02 UTC] PHP Notice:  fwrite(): send of 25 bytes failed with errno=1 Operation not permitted in /home/sefgstxb/public_html/lgsl_files/lgsl_protocol.php on line 1156

plz help me solve this problem....

@Rosenstein
Copy link
Contributor

Is fsockopen enabled or disabled on admin page?

If it is disabled, ask your host to enable outbound connections.

@BaxAndrei
Copy link
Contributor

Make sure to use same php version for cron as one that you use for website.
Ex: /usr/local/bin/php /home/baxandre/cleanup.php or /usr/local/bin/ea-php80 /home/baxandre/cleanup.php

@Sh4d0wless
Copy link
Author

i added simple code in lgsl_cron.php

if(function_exists("fsockopen")) {
 echo "Function Exists";
 } else {
 echo "Function not exists";
}

Result is - Function Exists

CRON: /usr/local/bin/ea-php74 /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php
site is on PHP 7.4 with LGSL 6.21

may be issue is in outbound 80/443 ports ?

or any other ideas?

@Rosenstein
Copy link
Contributor

Rosenstein commented Nov 9, 2024

Try this

<?php
if(fsockopen("websistent.com",80))
{
print "I can see port 80";
}
else
{
print "I cannot see port 80";
}
?>

@Sh4d0wless
Copy link
Author

Sh4d0wless commented Nov 9, 2024

can be fwrite() error caused only by fsockopen

@Sh4d0wless
Copy link
Author

Sh4d0wless commented Nov 9, 2024

with ur code i got "I can see port 80"

then i tested with other (game ip:port)

if(fsockopen("80.241.245.222",1337)) { print "I can see port 1337"; } else { print "I cannot see port 1337"; }

and got this

Warning: fsockopen(): unable to connect to 80.241.245.222:1337 
(Connection refused) in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 20
I cannot see port 1337

i doubt fsockopen have to work for websites coz its allowed from php.ini with allow_url_fopen = On

but does not work for game IP:PORTs :(

@Rosenstein
Copy link
Contributor

Rosenstein commented Nov 9, 2024

You should have tested port 27105 instead of 1337 as there is no app listening on that port at the destination IP

Your host whitelisted some ports.
Ask them to whitelist the ports that you need

@Sh4d0wless
Copy link
Author

Warning: fsockopen(): unable to connect to 80.241.245.222:27105 (Connection refused) in /home/sefgstxb/public_html/lgsl_files/lgsl_cron.php on line 20
I cannot see port 1337

same

@Rosenstein
Copy link
Contributor

Rosenstein commented Nov 10, 2024

This is host issue.
Since lgsl is on the same box as the game servers it may be a NAT Loopback problem.
Send a ticket to your host and ask them (they might need to enable outbound connections).
If they refuse, ask them to enable traffic on the specific ports that you need.

@Sh4d0wless
Copy link
Author

Sh4d0wless commented Nov 10, 2024

so as i understend its shld be 80 & 443 outbound ports for fsockopen ?
and
is fwrite() error caused only by fsockopen ?

@Rosenstein
Copy link
Contributor

Rosenstein commented Nov 11, 2024

so as i understend its shld be 80 & 443 outbound ports for fsockopen ?

Yes and no.
Excerpt from faq from one of the hosting companies:

The fsockopen function will work for outbound connections to any URL on port 80 (HTTP) or 443 (HTTPS). If fsockopen attempts to use another port, it will not work until we add that port to the firewall.

is fwrite() error caused only by fsockopen ?

Yes

@Sh4d0wless
Copy link
Author

tnx for ur help and time... <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants