Search code examples
rubyxml-rpcopenx

How do deal with OpenX XMLRPC authentication / sessions


I am having trouble with Openx; here is the issue

OpenX::Services::Base.connection returns the class variable @@connection which is populated by OpenX::Services::Base.connection if it has previously not been initialized.

The problem with it being a class variable is that it persists across connections, which means if there is a lull in activity, the XMLRPC session between my site and OpenX will time out, and the OpenX API has no provisions for communicating an expired session, which would be wasteful anyways as it would require a request before every communication just to verify that the session was still valid.

What I think would be a better way to do it would be to instantiate a connection at the beginning of any request that needs OpenX support, and to close it at the end, ensuring that there is no possibility of a session time-out on the XMLRPC side of things.

Has anyone else encounted this when using OpenX / OpenX XMLRPC? If so how did you resolve this issue?


Solution

  • I have a try/catch block around the OpenX RPC call, and I wrote an exception translator. If I detect a session timeout I will execute a again the login operation, I will take the new session id and I will run the failed OpenX call again. It is a little bit more complicated than having a cron job in order to keep the session alive but more performant and robust (in my opinion).