Currently there's no way to route non-HTTP traffic to your app. Heroku binds Ruby web servers to various ports and hosts behind the scenes and then routes traffic to those processes based on the Host in your HTTP header. Requests lasting longer than 30s are assumed to be hung, and are terminated.
From a design perspective, long running queries present a significant performance problem. With a single dyno, any request that lasts 30 seconds (or even 2 seconds) is preventing any other user from accessing your site for the entire duration. Instead, a more performant design is to quickly serve a page in a base state and use a worker thread to process the content in the background while pulling results in via javascript. This can be done simply using modern web development tools.
In the event that you have a long-running process that you don't need to communicate with via a socket you can simply use a worker. I'd recommend a tool like MongoDB for storing results of computations and a library like Delayed::Job for queuing.
Having said all that, there are definitely reasonable use cases which demand longer running processes and non-HTTP traffic, but at the moment Heroku doesn't support them.