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

Undefined constant SOCKET_EAGAIN in Windows #619

Closed
MaxwellZY opened this issue Nov 15, 2018 · 5 comments
Closed

Undefined constant SOCKET_EAGAIN in Windows #619

MaxwellZY opened this issue Nov 15, 2018 · 5 comments
Milestone

Comments

@MaxwellZY
Copy link
Contributor

MaxwellZY commented Nov 15, 2018

I have found a compatibility bug at \PhpAmqpLib\Wire\IO\StreamIO.php line 88:

self::$ERRNO_EQUALS_EAGAIN = 'errno=' . SOCKET_EAGAIN;

I checked the PHP source code, the SOCKET_EAGAIN constant is referred from EAGAIN, but cannot be accessed in Windows (EWOULDBLOCK instead in Windows). Thus the program would crash due to this undefined constant. Please kindly check whether defined SOCKET_EAGAIN before use it, or replace it by SOCKET_EWOULDBLOCK, also it's an alias for SOCKET_EAGAIN in Linux.

// patch type1:
self::$ERRNO_EQUALS_EAGAIN = 'errno=' . (defined('SOCKET_EAGAIN') ? SOCKET_EAGAIN : SOCKET_EWOULDBLOCK);

// patch type2:
self::$ERRNO_EQUALS_EAGAIN = 'errno=' . SOCKET_EWOULDBLOCK;
@lukebakken
Copy link
Collaborator

If you have time, a pull request would be appreciated. Thanks!

@nifrasismail
Copy link

When I hardcode the value for this, it is working for me

        self::$ERRNO_EQUALS_EAGAIN = 'errno=' . SOCKET_EAGAIN;
        self::$ERRNO_EQUALS_EWOULDBLOCK = 'errno=' . SOCKET_EWOULDBLOCK;
        self::$ERRNO_EQUALS_EINTR = 'errno=' . SOCKET_EINTR;

@nifrasismail
Copy link

I fixed this issue by enabling the socket ext in php

@M0H3N
Copy link

M0H3N commented Mar 16, 2019

@nifrasismail
How did you enable socket ext ?

@nifrasismail
Copy link

nifrasismail commented Mar 19, 2019

from your php.ini uncomment this

;extension=php_sockets.dll

P.S if you are using docker install the extension on your Dockerfile

RUN docker-php-ext-install sockets

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

4 participants