heroku different port for Rest service - heroku

I have a java application which exposes a port to receive data from outside. I'm wondering how to make heroku also expose this port? I now expose the port to 8170, when I tried to connect it, I always get couldn't connect to host error. I tried to change the $PORT variable, but it always says it fails to bind to port. Could anyone help me on this?
Many thanks in advance!

Per Can a Heroku app use different/multiple ports?, you can only use the default ports of 80 and 443 for apps on Heroku.
Changing $PORT is unlikely to help; this is the mechanism Heroku uses to tell your app what port to run on within the server; it then puts a proxy between the real network port and your application.
If you really, really must expose HTTP on a non-standard port, you'll need to find another deployment mechanism. My recommendation would be to try to update your REST client to not require a non-standard port.

Related

Why does this heroku-hosted java app return 404?

I have a .jar file that listens for requests and streams music (lavalink). When I run it locally on my own computer, I can make requests to it and everything works fine. However, when I move it to be hosted on heroku, trying to send a request to the app just results in nothing happening.
I am using "https://my-app-name.herokuapp.com" as the hostname to connect to, and the port I am using is the one that shows up in the logs:
Starting process with command java -Dserver.port=27955 -jar Lavalink.jar
^this one
Am I doing something wrong? Can Heroku maybe not find the java app? Do I need to provide a different hostname or port?
Turns out that Heroku always listens on port 80 for external requests and then routes the traffic to the port that shows up in the logs. Rewriting the config file (that the java app uses) during build to use the port that shows up in the logs seems to work.

Spring boot app cannot connect to RabbitMQ on kubernetes Cluster

I deployed a RabbitMQ server on my kubernetes cluster and i am able to access the management UI from the browser. But my spring boot app cannot connect to port 5672 and i get connection refused error. The same code works , if i replace my application.yml properties from kuberntes host to localhost and run a docker image on my machine.I am not sure what i am doing wrong?
Has anyone tried this kind of setup.
Please help. Thanks!
Let's say the dns is named rabbitmq. If you want to reach it, then you have to make sure that rabbitmq's deployment has a service attached with the correct ports for exposure. So you would target http://rabbitmq:5672.
To make sure this or something alike exists you can debug k8s services. Run kubectl get services | grep rabbitmq to make sure the service exists. If it does, then get the service yaml by running 'kubectl get service rabbitmq-service-name -o yaml'. Finally, check spec.ports[] for the ports that allow you to connect to the pod. Search for '5672' in spec.ports[].port for amqp. In some cases, the port might have been changed. This means spec.ports[].port might be 3030 for instance, but spec.ports[].targetPort be 5672.
Do you are exposing TCP port of rabbitMQ to outside of cluster?
Maybe only management port has exposed.
If you can connect to management UI, but not on port 5672, maybe indicate that your 5672 port is not exposed outside of cluster.
Obs: if I not understand correctly your question, please let me know.
Good luck

How to point shared load balancer http/https port to specific port of my Jelastic Docker container

My app listens stuff on port 8082 (or whatever one).
I want to configure shared load balancer to route all requests from 443 port (HTTPS) to this port. As far as I understand, this is done by some Jelastic magic during container creation. So far so good, everything worked fine.
But after I've updated base image for my Docker app (from openjre-152 to openjre-171 or something like this) SLB stopped to re-route traffic to my app.
Is there way to change/setup this internal configuration manually without environment re-creation?
You should use JELASTIC_EXPOSE as written in docs, however, it's not clear that your traffic will be redirected and ssl-terminated by SLB.

How should I communicate with my server on Heroku if I don't know the port?

From what I have understood, Heroku assigns a port every time you deploy. I have an android app that is supposed to communicate with my server that I will deploy to Heroku.
But if I don't know the port, how do I make a POST call?
Does that mean Heroku is not suitable for this application?
I am using Java Spark, if that's relevant.
Your dyno internally uses a random port. Only the heroku router should communicate with that port.
You instead need to use the appname.herokuapp.com subdomain provided with your app, on port 80 or 443.
The router will then automatically forward the request to one of your dynos in random.
So yes, you can use heroku for your android app. Just make requests on the herokuapp.com subdomain like you would do anywhere else.

Creating static IP for heroku to connect to external firewall

I'm trying to connect to ObjectRocket with my Heroku app, I'm running into a little problem where I can't seem to set a static IP (tried Proximo for that).
ObjectRocket requires me to define all IP's connecting to the database, so I need a non-dynamic IP for my heroku app.
How could I create this, or is this not possible with Heroku?
Hello you can use this answer to see how to use NGINX as a reverse proxy.
https://stackoverflow.com/a/27874505/1345865
http://blog.talenox.com/post/107675614745/how-to-setup-static-ip-on-heroku
If in your case where you require a outbound reverse proxy, setup an AWS instance and use NGINX to point it to ObjectRocket as your backend

Resources