Stale connections with Asterisk realtime


We seem to have an Asterisk with Asterisk realtime when using it for MusicOnHold. We are using an external database and we have a stateful firewall in front of the asterisk box. If there is no packets for a considerable amount of time the connection will go stale and the next time Asterisk tries to query MySQL asterisk seems to just “hang”. Is there any place in Asterisk where I can configure Asterisk to say send a ping every X seconds to MySQL to the connection stays alive? If not the hack I thought of was to have a “dummy call” loop over and over in and out of MusicOnHold say every 5 seconds which should cause the connection to stay up (unless there is pooling and then who knows how I will go out). Any ideas?

It is best to host the database on the Asterisk machine. Otherwise you are making failures more likely.

@david551 We don’t always get what we want… In this case it’s a cluster of boxes in AWS and it makes no sense to have to manage 10 DB’s when everything else is able to go to one DB.

There is no option to regularly ping. I have seen this hanging though from the MySQL ODBC connector. If I recall switching to the MariaDB ODBC connector instead worked better. Or it might have been vice versa. The hanging itself is caused by the connector blocking.

@jcolp I assume it’s my firewall that is causing the issue. Could asterisk be modified to send pings in regular intervals? Is there connection pooling? I was thinking of simply having a call go in and out of MOH every 30 seconds causing the connection to stay active.

Code is code, so possibly. You’re fundamentally working around an issue in the underlying ODBC connector in that it blocks indefinitely there. There is connection pooling in res_odbc, but if we call a UnixODBC function and it just blocks indefinitely due to the connector that won’t do anything. You can try your call thing, but if some other issue with the connection occurs that exhibits the same indefinite blocking even with that then it’ll still happen.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.