If i use the CURLOPT_TCP_FASTOPEN option in my code , then i get the following error.
Use of undefined constant CURLOPT_TCP_FASTOPEN - assumed
'CURLOPT_TCP_FASTOPEN'
The CURLOPT_TCP_FASTOPEN is a supported option in php 7.4.5 interface .
php -v
PHP 7.4.5 (cli) (built: Apr 14 2020 12:54:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
curl -V
curl 7.70.0 (x86_64-redhat-linux-gnu) libcurl/7.70.0 NSS/3.44 zlib/1.2.7 libpsl/0.7.0 (+libicu/50.1.2) libssh2/1.9.0 nghttp2/1.31.1
Release-Date: 2020-04-29
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL UnixSockets
What am i doing wrong here ?
Edit 1:
Here are additional info corresponding to YouriKoeman's overview
Kernel version : 3.10.0-1062.12.1.el7.x86_64
OS : unix (Centos 7.x)
curl --tcp-fastopen -L http://www.google.com return the following error:
curl: (55) Send failure: Operation not supported for curl --tcp-fastopen -L http://www.google.com
I chose to answer in a more broad way to hopefully help more poeple when they encounter issues relating to this and google for answers
(Note: php runtime and Loaded extensions can differ between the CLI and when accessed from a webserver).
What are the system requirements for this feature?
The feature CURLOPT_TCP_FASTOPEN you want to use has some system requirements that have to be met
They are the following:
You must have Kernel version > 3.6 (linux)
You must have PHP 7.0.7 or higher
You must have Curl(program) AND php{your/version}-curl 7.49.0 or higher
You must have a *nix type of operating system (macos, linux, bsd)
how to debug What requirement is not being met?
The fact that the constant is not defined is a red flag that one of these dependencies is not met, but how do i figure out which?
kernel version
This one is easy, run the following command:
uname -r.
It must be greater than 3.6
Curl version and build options
The best way to check if the functionality is available in curl is to call curl from the cli with this option, like:
curl --tcp-fastopen -O http://google.com
If this request goes successfully, curl is configured correctly on your system, so the problem lies within php
PHP version and extensions
For webserver
use phpinfo() to check if the php version is greater than 7.0.7 And that the php-curl extensions are loaded
For CLI
in the command line type php -v the version should be greater than 7.0.7.
To check the extensions type the following into your command line php -m | grep curl this command should return curl, if nothing is returned the curl extension is not loaded for the php cli.
The issue was that tcp fast open is not enabled by default until kernel version 3.13.
To enable TCP Fast Open on Centos 7:
1.Add tcp_fastopen in sysctl.d
echo "net.ipv4.tcp_fastopen=3" > /etc/sysctl.d/30-tcp_fastopen.conf
2.Restart sysctl
systemctl restart systemd-sysctl
3.Verify sysctl setup for tcp_fastopen
cat /proc/sys/net/ipv4/tcp_fastopen should output 3
Related
I am having some difficulty using PHP Xdebug with the PHP's internal server provided by later releases of Eclipse. I am running Eclipse for PHP Developers Version: Oxygen.3a Release (4.7.3a). Interestingly enough Xdebug is working quite well with Apache 2, but not the internal PHP server.
Note that the PHP internal server is running. I can use ‘Run As – 1Run on Server’ to run a phpinfo PHP script and a helloworld PHP script. In these cases, the PHP internal server is started with the expected operands. The Linux ps command returns:
/usr/bin/php -S 127.0.0.1:8000 -t /home/peter/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/htdocs
Note that port 8000 is used to start the internal PHP server (correctly as best I can tell) and no –n operand is specified. This causes the /etc/php/7.0/cli/php.ini file to be processed (correctly as best I can tell).
Note that port 80 was originally used to run this server. Of course, port 80 is restricted to root applications. The change to port 8000 was required to get the internal PHP server to start at all.
Also note that checking ‘Use system default php.ini configuration’ and clearing the PHP ini file (optional) field in the PHP Executable preferences was required to get rid of the –n operand.
Also note that I am having some difficulty switching between ‘Run As’ and ‘Debug As’. In some cases I get a message showing that the required port (8000) is already in use. However, I have not found a way to reproduce this problem so far.
Using the procedures described above, the debug internal PHP server was started without the –n operand and is processing the php.cli file. The Linux ps command returns:
/usr/bin/php -S 127.0.0.1:17278 -t /home/peter/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/htdocs
One question is why port 17278 was specified, rather then the expected port (8000). Running phpinfo() shows that Xdebug appears to be installed in the debug internal web server. A few settings include:
xdebug support – enabled
IDE Key – peter (my userid on this machine)
DBGp – Common DeBuGger Protocol - $Revision: 1.145 $
xdebug.remote.enable – on
xdebug.remote.port – 9000
I tried to debug helloworld.php. The console has the following two messages. The first shows a 404 code. The second shows a 200 code:
[Sun Apr 22 17:36:20 2018] 127.0.0.1:50358 [404]: /?start_debug=1&debug_fastfile=1&use_remote=1&ZRayDisable=1&send_sess_end=1
&debug_session_id=1003&debug_start_session=1&debug_port=10137 - No such file or directory
[Sun Apr 22 17:36:20 2018] 127.0.0.1:50362 [200]: /Server-docroou/helloworld.php?start_debug=1&debug_fastfile=1&use_remote=1&ZRayDisable=1&send_sess_end=1
&debug_session_id=1003&debug_start_session=1&debug_port=10137
Note that the debug port is specified as 10137. Perhaps this is causing the problem. Port 10137 is normally used by the Zend Debugger which I am not using.
Does anyone have any ideas? Thank you in advance.
Problem fixed in PDT 6.0 : https://bugs.eclipse.org/bugs/show_bug.cgi?id=533928 ;)
My client gave me a login to their ftp and I uploaded a code. Unfortunatelly when I try running a website I get PHP Parse error no matter what it is there (as if PHP would not be functioning properly).
Examples:
index.php
<?php
echo 'test';
gives me an error:
PHP Parse error: syntax error, unexpected ''test'' (T_CONSTANT_ENCAPSED_STRING)
What if I try php functions?
<?php
phpinfo();
gives me an error:
PHP Parse error: syntax error, unexpected 'phpinfo' (T_STRING)
Does anyone have any clue what is going on?
P.S. Client does not want to me to give login credentials to server since "there are a lot of important data"...
UPDATE
Using <? or <?= instead of <?php did the job. But I would love to have <?php working instead since project contains of hundreds of php files opening with <?php.
phpinfo() information:
PHP Version 5.6.31
System Linux cp60.webserver.pt 2.6.32-673.26.1.lve1.4.29.el6.x86_64 #1
SMP Tue Jun 20 13:27:00 EDT 2017 x86_64 Build Date Jul 17 2017 09:37:47
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /opt/alt/php56/etc
Loaded Configuration File /opt/alt/php56/etc/php.ini
Scan this dir for additional .ini files /opt/alt/php56/link/conf
Additional .ini files parsed /opt/alt/php56/link/conf/alt_php.ini
PHP API 20131106
PHP Extension 20131226
Zend Extension 220131226
Zend Extension Build API220131226,NTS
PHP Extension Build API20131226,NTS
Debug Build no
Thread Safety disabled
Zend Signal Handling disabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp,
udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters zlib., bzip2., convert.iconv., string.rot13,
string.toupper, string.tolower, string.strip_tags, convert.,
consumed, dechunk, mcrypt., mdecrypt.
In the end it was encoding issue by FileZilla... I change Transfer option to "Binary" and now it works as usual.
I've read a lot of issues with php file encoding while transfering using ftp and most of them have symptoms as mine (php opening tag not working). I will leave the question so someone with the same problem would find a solution.
I am running PHP 5.2.13 on a Windows Server 2008 R2 machine (Windows 7 equivalent).
I'm mostly writing this just because I get a google dead end on searching for the warning and I'm trying to add something for it.
I am getting the following notice / warning:
Use of undefined constant OPENSSL_ALGO_DSS1 - assumed 'OPENSSL_ALGO_DSS1'
openssl_verify() expects parameter 4 to be long, string given
When running this line of code:
return openssl_verify($data, $signature, $this->getPublicKey(), OPENSSL_ALGO_DSS1);
Obviously the second warning is caused by the first.
However the problem isn't that the OpenSSL library isn't loaded, as I have the following output from phpinfo:
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8k 25 Mar 2009
This is working on all other machines that it has been tested on, so there is something machine specific.
The only difference I have spotted is the following from phpinfo:
Registered Stream Socket Transports tcp, udp
vs on machines where it is working:
Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls
But I'm not sure if that's a red herring or not.
My solution for the problem was to uninstall PHP completely and run the php-5.2.13-nts-x86.msi installer and install the OpenSSL library through there.
I had done a manual installation of the OpenSSL library rather than using the Windows installer.
I now do have the following in phpinfo:
Registered PHP Streams php, file, data, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls
As far as I can tell even according to the openssl installation documentation there shouldn't be a requirement to have to install using the installer. On other machines I haven't had this problem. Altering the 'Registered Stream Socket Transports' to include ssl should only require installing the open_ssl library and adding a line to the php.ini file e.g. this answer.
I am trying to get rid of this error when sending notifications using the ssl protocol in php code:
"Failed to connect: 1976434032 Unable to find the socket transport
\"ssl\" - did you forget to enable it when you configured PHP?"
1: The system is SUSE Linux Enterprise Server 11 SP3.
2: When doing this command rpm -qa | grep ssl, I get:
- openssl-certs-1.97-0.3.1
- openssl-0.9.8j-0.80.1
- libopenssl0_9_8-0.9.8j-0.80.1
- libopenssl0_9_8-32bit-0.9.8j-0.80.1
3: Inside the php.ini file, this line has been uncommented and apache has been restarted:
- extension=php_openssl.dll
4: Looking at phpinfo, i have these settings:
- Registered PHP Streams => php, file, glob, data, http, ftp
- Registered Stream Socket Transports => tcp, udp, unix, udg
- Registered Stream Filters => string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, convert.iconv.*
THIS SECTION DOES NOT APPEAR IN THE FILE:
- openssl
- OpenSSL support => enabled
- OpenSSL Library Version => OpenSSL 1.0.1e-fips 11 Feb 2013
- OpenSSL Header Version => OpenSSL 1.0.1e-fips 11 Feb 2013
According to these informations, it looks like openssl is not installed or configured properly. But I have no clue how to fix the issue.
What should i do to enable openssl in php to get rid of this message:
"Failed to connect: 1976434032 Unable to find the socket transport
\"ssl\" - did you forget to enable it when you configured PHP?"
Does anyone could help me?
First time asking a question here, please be gentle :-)
I'm writing a PHP command-line script on a Synology box to fetch files via ftps, and start out with this bit:
$ftp = ftp_ssl_connect("ftp.example.com");
When run from the command line, I get
Fatal error: Call to undefined function ftp_ssl_connect() in ...
phpinfo() tells me:
...
Registered PHP Streams => php, file, glob, data, http, ftp, https, ftps, zip, compress.zlib, compress.bzip2
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
...
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.1p-fips 9 Jul 2015
OpenSSL Header Version => OpenSSL 1.0.1p-fips 9 Jul 2015
and /etc/php/conf.d/extensions.ini contains extension = openssl.so (without an initial ;)
It seems to me that all the prerequisites for ftp_ssl_connect() are in place.
fwiw:
$ uname -a
Linux DiskStation01 2.6.32.12 #5644 Wed Oct 28 12:36:45 CST 2015 armv5tel GNU/Linux synology_88f6282_213
What would be the next place to look?
Type php -m to see the compiled in modules, as PHP does not ship the FTP extension by default if not on Windows. Calling phpinfo() should also show the compiler switches used, and if they include --enable-ftp.
The curious thing is I just tried this on an RS812 of mine, and it shows both the FTP and OpenSSL moodules as included, and it works fine:
nas-name> php -r "ftp_ssl_connect('test');"
PHP Warning: ftp_ssl_connect(): php_network_getaddresses: gethostbyname failed
in Command line code on line 1
This indicates the ftp_ssl_connect is working but not being able to parse the supplied host name. I have no idea why yours would be different unless you compiled PHP yourself.
As mentioned in Niels solution the ftp-Module is missing in the default installation. I needed the module in the CLI version of PHP, but it was unavailable on all four of my Synology Devices (DS 412+, DS 410, RS812+ and RS814+).
Enabling the module in the Web Station settings did not help, but there is a solution for the CLI version in a Synology Forum Entry:
make sure that the ftp extension is selected within php settings of Web Station.
then edit /etc/php/php.ini to include a line like this:- extension = /volume1/#appstore/PHP5.6/usr/local/lib/php56/modules/ftp.so
that's it. No restarting of Web Station or the NAS is required, as php loads itself from the commandline each time a call is made to php.