This function should not know anything about requests or HTTP. Why not using the closure in `presence.js` and check if the connection is still valid ?