senaranya/HL7

this Exception is not catching in the method connection when the remote host is down

franciscoolmfdz opened this issue · 3 comments

PHP Warning: socket_connect(): unable to connect [111]: Connection refused in ....../aranyasen/hl7/src/HL7/Connection.php on line 66

the warning appear using with ip/port used SmartHL7 Message Receiver and turn off.
Probably you need to add socket_bind() and socket_listen() after socket_create().

Thank you for reporting the issue.

socket_bind() is optional for clients as the OS usually picks an unused port. I can add an additional argument to use a certain local port if the HL7 listener requires that, but that calls for additional logic to allow address-reuse and all. Please create a separate ticket if that's a requirement.

socket_listen() is only used by socket servers and won't be required by us.

I can wrap the socket_connect() call with try-catch, but I'd probably re-throw the same error "Connection Refused" with some additional info, e.g. server IP/Port. Will that help?

yes, thats great. thanks

Fixed @ release 1.5.0