ServicePoint,HttpConnectionHttp 1.1,httppipelining, Responons,stream.close internals? - httpwebresponse

In .net framework 3.5 , http 1.1 i.e persistent connections is used and pipelining is enabled bydefault. Could you please let me know it is neccessary to close stream or connection by calling httpresponse.close or stream.close method to release a connection for another http request to the same internet resourece ? My understanding is even if httpresponse.close or stream.close is not called then too httpconnection i.e. servicepoint should be able to server another concurrent request. Please confirm.

Related

"SocketException: No buffer space available" on Jersey Client

I am using jersey-client (1.9) for calling api and everytime when i need to call a webservice i create a new client instance :
Client client = Client.create();
WebResource webResource = client.resource(url);
ClientResponse response = webResource
.queryParam(PARAM1, param1)
.queryParam(PARAM2, param2)
.type(MediaType.APPLICATION_JSON)
.get(ClientResponse.class);
the problem is after a period of time i get this exception :
com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: No buffer space available (maximum connections reached?): connect
If anyone could help me figure it out I would be very grateful .
You have a resource leak. (Connections and InputStreams backing ClientResponses aren't being closed.) You can read a ClientResponse entity so that its associated resources are automatically closed by calling ClientResponse.readEntity(), or you can manually close them via ClientResponse.close().
The following documentation may not exactly apply to the version of Jersey that you're using, but it's insightful:
Jersey Client API, Closing connections
If you will provide additional details about the OS (windows/linux), more of the code or the type load your service is experiencing - all would help to provide a better answer.
A good guess though is that your OS is running out of sockets ports. Different OS's have different defaults and different ways of configuring how many sockets are available to establish TCP sockets.
though not exactly the same question, this one is similar can shed some light on your situation: java.net.SocketException: No buffer space available (maximum connections reached?): connect
There is also a write up about the same exception here:
http://dbaktiar-on-java.blogspot.com/2010/03/hudson-shows-buffer-space-available.html

java.net.SocketException: Connection reset on reaching 3000 users in JMeteR

All required changes have been done to respective files like:
stalecheck=true,
keepalive is checked from HTTP request defaults,
retrycount=1,
hc.parameters file changes,
Socket timeout is 240000
Still we see "java.net.SocketException: Connection reset" in response data however I see the valid requests been passed to Server.
The issue wasnt till we reach 3000 users, worked smoothly till 3000 users.
Connection Reset has a lot of meaning, possible reasons are:
One of the server components is not able to handle load so it closes connections on its side
On JMeter side, check that you running in NON GUI mode and that neither JMeter JVM nor injector machine are overloaded which could explain this. See:
https://jmeter.apache.org/usermanual/get-started.html#non_gui

JMeter TCPSampler - how to handle a custom protocol with a periodic keep alive?

I am relatively new to JMeter however I have been doing Performance testing for almost a decade.
I am working with a proprietary TCP protocol that sends a keep alive periodically - through the existing TCP connection.
I am struggling to understand how I can fork the JMeter 'thread group' to handle a TCP Keep alive received over the same TCP session.
Any ideas?
Thank you brainstrust!
edit: I'm using the TCPsampler and have read the help page. I'll try to provide some more detail shortly about what's happening and how the protocol is written.
edit2: Unfortunately because it's a propriety protocol I cannot reveal the exact nature of the protocol itself but it's largely irrelevant to the problem I'm facing.
Basically, I use the 1st TCP sampler to 'start/authenticate' the session with the server. This is configured the following options:
1. TCPClient classname: LengthPrefixedBinaryTCPClientImpl (my protocol is implemented this standard way)
2. Re-use connection ON.
3. Close connection OFF.
4. Set NoDelay OFF.
5. SO_Linger: nothing
6. Text to send: my hex code for the protocol (this is correct)
I get the response from the first TCP request and then I want to start interacting, however in the session, the server sends a keep alive mid-stream, so occassionally when I send a request, I get an unexpected keep alive response instead (it's an open stream of data).
This is what I would like to solve.
I attempted to use a recursive test fragment, so that on KeepAlive response, it would send the request again however one cannot recurse the test fragments (it throws a Java error on Run attempt).
I hope this gives more context! Thank you for your patience (I'm a newbie SO user!)
Please check the below options if it helps with you sceario:-
If "Re-use connection" is selected, connections are shared between
Samplers in the same thread, provided that the exact same host name
string and port are used. Different hosts/port combinations will use
different connections, as will different threads. If both of "Re-use
connection" and "Close connection" are selected, the socket will be
closed after running the sampler. On the next sampler, another socket
will be created. You may want to close a socket at the end of each
thread loop.
If an error is detected - or "Re-use connection" is not selected - the
socket is closed. Another socket will be reopened on the next sample.
The following properties can be used to control its operation:
tcp.status.prefix text that precedes a status numbertcp.status.suffix
text that follows a status numbertcp.status.properties name of
property file to convert status codes to messagestcp.handler Name of
TCP Handler class (default TCPClientImpl) - only used if not specified
on the GUI
For more details:-https://jmeter.apache.org/usermanual/component_reference.html#TCP_Sampler

How to find Oracle server crash from OCI Client program

I have written a oracle client program using OCI library.
client send a request to server and hung because server crashed and not intimated to client.
How can i find server status from client side(using OCI API).?
Thanks
I think Oracle db module for Asterisk had a nice DCD(dead connection detection) implemented. There are various approaches(server side, client side).
In your case the easiest way would be to use TCP keepalive. Use enable=broken directive in tnsnames.ora.
Purpose
The keepalive feature on the supported TCP transports can be enabled
for a net service client by embedding (ENABLE=BROKEN) under the
DESCRIPTION parameter in the connect string. Keepalive allows the
caller to detect a dead remote server, although typically it will take
2 hours or more to notice. Operating system TCP configurables, which
vary by platform, define the actual keepalive timing details.
net_service_name=
(DESCRIPTION=
(enable=broken)
(ADDRESS=(PROTOCOL=tcp)(HOST=sales1-svr)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-svr)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com))
Just beware you will also need root privileges. With default setting Linux kernel starts sending keepalive packets after 2 hours of inactivity. So you also have to change tcp_keepalive_time and tcp_keepalive_intvl in /etc/sysctl.conf. This is global server side settings and Oracle can not yet set keepalive interval for a single TCP connection.
One more comment: I recall there is some function called OCIPing.
This one can be used for testing too. But I'm not sure how to distinguish long running queries from dead server situation.

TLS/SSL session resume on FTP transfer connection with OpenSSL

I'm open source developer implementing FTP client (WinSCP).
I'm trying to resume TLS/SSL session from the FTP control socket on the transfer socket.
Some FTP servers started to require this.
E.g. vsftpd:
https://scarybeastsecurity.blogspot.com/2009/02/vsftpd-210-released.html
I'm using OpenSSL to implement SSL layer.
I've tried the obvious way to implement the session resume, i.e. to use SSL_get1_session and SSL_set_session, like here:
https://www.linuxjournal.com/article/5487
Though it does not work. I'm still not able to connect to any FTP server requiring TLS session resume (like the vsftpd).
I have suspicion that the problem may be due to in my case, there are two parallel TLS connections, which cannot share the same TLS session. Which is different to the example on linuxjournal.com, where the first connection is closed before the other is opened.
I have also tried several ways to clone the session, e.g. using i2d_SSL_SESSION/d2i_SSL_SESSION. Didn't help either.
I'm really stuck here.
Thanks in advance for any help.
Using the SSL_get1_session and the SSL_set_session worked in the end. I must have used them incorrectly when trying the first time.
Once the TLS/SSL session on the control connection is established, use SSL_get1_session to retrieve the session.
I specifically do it from a callback set by the SSL_set_info_callback, when where & SSL_ST_CONNECT.
But for TLS 1.3 (SSL_version >= TLS1_3_VERSION), I had to use SSL_CTX_set_session_cache_mode with SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_NO_INTERNAL_STORE | SSL_SESS_CACHE_NO_AUTO_CLEAR, and use a callback set by SSL_CTX_sess_set_new_cb.
Call the SSL_set_session with the reference to the control connection session, when setting up TLS/SSL session for the data connection.
You must specifically enable client session caching on your SSL_CTX object with:
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT);
You may also need to increase the default session cache timeout (the default is 300 seconds), using SSL_CTX_set_timeout().
(You must also be creating your SSL objects from the same SSL_CTX object).

Resources