What is the best way to ignore closed sockets and keep processing? I'm trying to work with a proxy between my client/server, and esp in the case of Keep-Alive, you're never sure when a socket will close. I want the httest script to simply ignore the close and open a new one for the next _REQ or _RES.
The following server fails with this error, because there is a _CLOSE between the client's 2 _REQ's.
error: SRV0-0 End of file found(70014) FAILED
I did this as a modification of test/simple.htt:
INCLUDE $TOP/test/config.htb
SERVER $YOUR_PORT
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Length: AUTO
__
__Hello World
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Length: AUTO
__
__Hello World
END
A similar thing happens when I move the _CLOSE from between the SERVER's two _RES's, to between the CLIENT's two _REQ's. If I put _CLOSE in both locations, it works fine. Or, if I remove the _CLOSE in both locations, its also fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, _AUTO_CLOSE works well for the CLIENT side. How about the SERVER side though? I don't necessarily get a Connection: Close prior to the socket being closed, so I'll get errors like the above. I tried to simulate that with the modification to simple.htt above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually as long as I do not send a "Connection: close" header from server, the proxy should not close, only if I wait too long. I usualy do close every 10 request or so. Or after a long sleep. With this you can test your socket connection:
_SOCKSTATE STATE
_IF "$STATE" MATCH "CLOSED"
_CLOSE
_END IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah now I get it. Yes if you run CLIENT SERVER directly you have to keep track of the _CLOSE. If you close on SERVER side you have to close on CLIENT side. This ist must have.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Lets say I have the above SERVER code running on a host with a proxy in front of it. Its possible for the proxy to open a connection to the SERVER (at which point the SERVER is probably sitting on a _WAIT), but if no clients send requests, the proxy may just close the connection after a timeout. When this happens, the SERVER code gets an error like "End of File". I want the SERVER code to keep going though.
The _SOCKSTATE check seems like it would be okay, I can't seem to make it work. The current worker thread running the SERVER body will error out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This works great - Matching anything to effectively ignore. I had tried _ERROR before with a specific error message to ignore, but if the error didn't occur the test would fail.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is the best way to ignore closed sockets and keep processing? I'm trying to work with a proxy between my client/server, and esp in the case of Keep-Alive, you're never sure when a socket will close. I want the httest script to simply ignore the close and open a new one for the next _REQ or _RES.
The following server fails with this error, because there is a _CLOSE between the client's 2 _REQ's.
error: SRV0-0 End of file found(70014) FAILED
I did this as a modification of test/simple.htt:
INCLUDE $TOP/test/config.htb
CLIENT
_REQ $YOUR_HOST $YOUR_PORT
__GET /your/path/to/your/resource?your=params HTTP/1.1
__Host: $YOUR_HOST
__
_WAIT
_CLOSE
_REQ $YOUR_HOST $YOUR_PORT
__GET /your/path/to/your/resource?your=params HTTP/1.1
__Host: $YOUR_HOST
__
_WAIT
END
SERVER $YOUR_PORT
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Length: AUTO
__
__Hello World
_RES
_WAIT
__HTTP/1.1 200 OK
__Content-Length: AUTO
__
__Hello World
END
A similar thing happens when I move the _CLOSE from between the SERVER's two _RES's, to between the CLIENT's two _REQ's. If I put _CLOSE in both locations, it works fine. Or, if I remove the _CLOSE in both locations, its also fine.
If your proxy do handle connection close correctly with a "Connection: close" header you can add
_AUTO_CLOSE on
on CLIENT side. This will close connection on a "Connection: close" header from server/proxy. If this do not work for you come back
Yes, _AUTO_CLOSE works well for the CLIENT side. How about the SERVER side though? I don't necessarily get a Connection: Close prior to the socket being closed, so I'll get errors like the above. I tried to simulate that with the modification to simple.htt above.
Actually as long as I do not send a "Connection: close" header from server, the proxy should not close, only if I wait too long. I usualy do close every 10 request or so. Or after a long sleep. With this you can test your socket connection:
_SOCKSTATE STATE
_IF "$STATE" MATCH "CLOSED"
_CLOSE
_END IF
Ah now I get it. Yes if you run CLIENT SERVER directly you have to keep track of the _CLOSE. If you close on SERVER side you have to close on CLIENT side. This ist must have.
Lets say I have the above SERVER code running on a host with a proxy in front of it. Its possible for the proxy to open a connection to the SERVER (at which point the SERVER is probably sitting on a _WAIT), but if no clients send requests, the proxy may just close the connection after a timeout. When this happens, the SERVER code gets an error like "End of File". I want the SERVER code to keep going though.
The _SOCKSTATE check seems like it would be okay, I can't seem to make it work. The current worker thread running the SERVER body will error out.
Yes then it will not work. The socketstate my be ok, but _WAIT will timeout on proxy side and the proxy will close, I see.
Try this
SERVER 8080 -1
_ERROR .*
_RES
_WAIT
…
_END
END
This spans a server vor every connection, if it fails it does not bother, because I expect an error ".*" means even SUCCESS is valid :)
Or this
SERVER 8080
_LOOP FOREVER
_ERROR .*
_RES
_WAIT
…
_END
_END
END
The same but connections are serial :)
This works great - Matching anything to effectively ignore. I had tried _ERROR before with a specific error message to ignore, but if the error didn't occur the test would fail.
I mostly do not use ignore errors, cause a test should be predictable and run allways the same way :)
And beware
_ERROR .*
_REQ 127.0.0.1 8080
__GET /foo HTTP/1.1
__Host: localhost
__
_EXPECT . "200 OK"
_WAIT
_END
will not fail! Even not if no 200 OK is returned.