Is there a way to re open a connection in db4o after I used connection.close? - db4o

versant db4o question :
is there a way to get the connection state from the connection object?
Thanks

No you cannot reopen a closed container.
The only thing you can do is to check if a container is already closed:
container.ext().isClosed()
If you want to reconnect you have the open another object container.

Related

Connection reset by peer on Azure

I have a web application running on an App Service on Azure cloud.
On the back-end I'm using a tcp connection to our database (Neo4j graph db), the best practice is to open the tcp connection and keep it alive in order to be more reactive when we perform queries.
The issue I encountered is that the database is logging the exception "Connection reset by peer";
reading on the web I found out that maybe Azure has a TCP timeout configured by default, I read it to be set up to 4 minutes, which could be my issue root cause.
Someone knows how to configure the tcp KEEP ALIVE to always for App Services on Azure?
I found on the web how to do it in Google cloud but nothing about Azure cloud.
Thank you in advance.
OaicStef
From everything I can find that is not an adjustable setting. Here is the forum link that says it will not be changing and that is a couple years old at this point. https://social.msdn.microsoft.com/Forums/en-US/32b76114-67a4-4e6b-ac45-61b0f0a0829f/changing-the-4-minute-request-time-out-for-app-services?forum=windowsazurewebsitespreview
I think you are going to have to add logic to your app that tests the connection, if it has been closed then either reopen it or create a new one. I don't know what language you are using to make any suggestions there.
Edit
I will add that the total number of TCP connections that can be open on a single App Service is about 6k, at least on the S1. Keep that in mind because if you don't have pooling on the server side or you are not disposing of those then you will exhaust that the TCP pool and you will start getting errors. I recommend you configure an alert for that.

What does this UWSGI error mean? " SIGPIPE: writing to a closed pipe/socket/fd "

There are a few questions related to this issue, but none of them actually help me understand what is going on.
The full error:
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request
It simply means that the client, i.e. the sites visitors, closed their connection.
Either by closing the browser, or through a connection error on their part.

Undefined TIdFTP status after error 10038 “Socket operation on non-socket”

I use a TIdFTP control to connect to an FTP server. It seems that my FTP connection is terminated by something (ftp server/firewall?) after 60 seconds of inactivity. Once the connection was terminated I cannot use the FTP control (TIdFTP) anymore because its status is undefined. For example, every time I try to REconnect I get the same (10038) error. However, FTP.Connected shows True. Trying FTP.Disconnect gives me a 'connection closed gracefully' error and the control remains connected. The only solution is to end the program and start it again.
The NAT Keep Alive is already set to 15000.
How to reset the status of the FTP control (how do I disconnect)?
I use a TIdFTP control to connect to an FTP server. It seems that my FTP connection is terminated by something (ftp server/firewall?) after 60 seconds of inactivity
TIdFTP has a NATKeepAlive property to avoid that exact issue from happening when connected through an FTP-unaware router/firewall. During a transfer, TCP keepalives are temporarily enabled on the control connection so it does not get closed prematurely.
However, FTP.Connected shows True.
That means the IOHandler.InputBuffer likely has unread data in it. Connected() is designed to return True if read operations can still be satisfied even if the socket has been closed.
Trying FTP.Disconnect gives me a 'connection closed gracefully' error
By default, Disconnect() sends a QUIT command to the server before closing the socket. Since the connection is already gone, that send fails.
Disconnect() has an optional ANotifyPeer parameter that you can set to False to skip the QUIT command.
You should also Clear() the IOHandler.InputBuffer after an unexpected disconnect to clear out any unread data.
The only solution is to end the program and start it again.
That is never the solution. Worse case, you could simply destroy the TIdFTP object and create a new one. But if you follow the steps above, you should not need to resort to even that.
You cannot keep TIdFTP open. The connection will be closed from server side for every timed out time.
As you use this component to fetch or put file to file server for a time interval, You can connect just before using the TIDFTP, and disconnect it after the usage. Then you do not need to bother about freeing the component and connection failures.

Need help wtih AMQP

We have a requirement for our project to listen to queues hosted in different machines. For example, we have 4 virtual hosts. I have created new instance of SimpleMessageListenerContainer for each hosts but i use one instance of MessageListener(it implements ChannelAwareListener so that i can manually ack). MessageListener is a bean managed by spring. I maintain a map of host and container instance when i create the containers. On receiving the message, check if i received the desired message from the host, get the container instance from the map (using #Resource) and stop listening to the host. Also manually ACK and store the message in the cassandra database.
Right now, there are times when some of the messages dont get persisted in the database and gets lost. I think it might be a race condition or due to the fact that i am using only one instance of messagelistener but i had to do that so that i can get the map(#Resource). Sorry if I am not making any sense. I am using the AMQP for the first time and trying to understand it. Any suggestions will be great. Thank you!
Why do you need manual ack? It's generally better to let the container take care of acks (AUTO). It will ack the message on success and nack it if the listener throws an exception.

iOS GCDAsynchsocket opening multiple connections

I am using GCDAsynchronousSocket in iOS to write/read data from a socket. For every 1 second I read/write this data. At the same time I want another connection to be established to read/write a different data on the same port. How do I do this? Is it correct to create a new GCDAsynchronousSocket Object?. Kindly help me with a solution.

Resources