I deployed my app on Heroku. It is a simple app that will throw back the message sent from its client version (running on my PC) back to the client. My server app prints the IP address of the machine it's running on so I can connect to it from my client . I do get to see the IP address of Heroku machine when I deploy and run it. However, I am not able to connect to it from my client version using that IP address(Connection timed out) . I have allowed the port I am using in my firewalls. I don't understand what I am doing wrong .
Pls help me solve it.
If you need to see my code let me know ( the app works fine locally on different terminals so I don't think it has a problem).
Your Heroku dyno (an isolated server) is behind a router. You can't use the IP address to connect to it.
Instead, you the URL https://[appname].herokuapp.com where "[appname]" is the name of your app.
You can also run heroku open from the command line.
Related
I am trying to start H2 in server mode to connect an application from another computer. But no matter how hard I have tried, I have not succeeded.
I have seen the documentation and to start the server from the command line is executed:
java -cp h2-2.1.214.jar org.h2.tools.Server -tcpAllowOthers
output:
TCP server running at tcp://127.0.1.1:9092 (others can connect)
PG server running at pg://127.0.1.1:5435 (only local connections)
Web Console server running at https://127.0.1.1:8082 (others can connect)
now from the other pc, as I understand I must execute the connection in the following way:
jdbc:h2:tcp://[server][:port]/[path]/[databaseName]
then it should be:
jdbc:h2:tcp://127.0.1.1:9092/home/mateo/database
But I have read that 127.0.1.1 only works locally. I have also noticed that when I open H2 Console in the examples I have seen, the machine's ip appears, that is to say: 192.168.X.
What am I doing wrong?
(Update)
I am currently using Linux.
I have launched the server from Windows and managed to connect it from Linux successfully following the above steps. But, I still don't understand why it doesn't work in Linux, in Windows it loads the server with the IP address of the machine. It makes me think that I have to do some additional configuration for Linux.
server running
You need to replace local IP address in your JDBC URL with real non-local IP address of your server (jdbc:h2:tcp://127.0.1.1:9092/*** -> jdbc:h2:tcp://192.168.1.4:9092/***, for example). H2 listens all network interfaces of the host, it doesn't matter which address was reported in “runnig at …” message.
You also may need to protect ports 8082 and 9092 from connections from untrusted systems if you have them in your internal network and from connections from external network (make sure your router or whatever you have doesn't redirect connections to the host with database server).
Actually, I am using GSM modem application which send SMS from my mobile, and mobile is a server to send messages from any java code.
While I run the spring boot application on localhost, it works perfectly for me, but after uploading it on server, it gives Connection time out error.
I am using Linux server provided by AWS ec2 instance.
Where is your server which handles SMS sending? It looks like it is located on your local machine, and after you have deployed your app to Amazon, there is no more routing from AWS to your local computer. You need to deploy your SMS server to routable (external IP) to let the AWS server access to SMS server
I am writing a small game server using Java.
I use TooTallNate-Java-Websockets library to create my websocket server.
Everything works when I run my server on localhost , I can connect to it from everywhere.However when I submit my app to Heroku , every time I try to establish a socket connection I get an error ECONNREFUSED (Connection refused).
Worth to mention , that when I am running my app with foreman which is supposed to emulate heroku environment , everything works as it should.
As a port for my websocket server I tried to use 8080 and many others in range between 5000 to 8000.
I can only guess what is going on there on heroku , as logs contain only basic info of http requests.
Please help , I am close to give up :(
EDIT
Here is what I have in my Proc file:
web: ./build/install/my-app/bin/my-app
UPDATE
Created a simple abstraction app to showcase the problem:
(Tested in foreman of course , and it works in local environment)
My html/js tester : Testerpage
My Main java Jetty server : Java Main
Console error message :
WebSocket connection to 'wss://test-websocket-yan.herokuapp.com:39773/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I am answering my own question to share how I've managed to connect to Java websocket server on Heroku.
Create your web socket server using Java , the implementation is up to you , you can use javax or Jetty websockets or TooTallNate-Java-Websockets , I've used Jetty. Here is my implementation . I have followed this example.
When connecting to your web socket on heroku use the following scheme ws:// + yourHerokuAppAdress + yourSocketEndpoint . The endpoint is the relative adress that your websocket is listening on , in my case it is "/socket" . No Need to specify port !
You must use the port that Heroku sets as the $PORT env var:
On Heroku, apps are completely self-contained and do not rely on runtime injection of a webserver into the execution environment to create a web-facing service. Each web process simply binds to a port, and listens for requests coming in on that port. The port to bind to is assigned by Heroku as the PORT environment variable.
For more see: https://devcenter.heroku.com/articles/runtime-principles#web-servers
You might just need to have REDIS_URL set. It was in REDISCLOUD_URL in my case.
I'm new to Openfire server so I'm not very sure on how to use it.
I'm trying to connect the server to an Android application which I had found on the web :
From the code , there is a host , port , username and password.
I tried input the following:
host : 127.0.0.1
port : 5222
However , the result of the application had failed which stated the error message that the server was not connected.
I had found on the web (Why can't I connect to the openfire server?) which the methods stated to edit the openfire.xml file. I had edited the file and the host number from the code into my ip address and it manage to work.
I'm just wondering why doesn't the original server ip address (127.0.0.1) not able to work while my ip address able to work?I'm also not sure if this problem only applicable to me alone.
Currently , I'm using emulator from Eclipse to run the application. But i believe in the future I will faced this issue again as I doubt using my own IP address able to work in the phone.
Edited :
I understand that Emulator needed network connection to connect to Openfire server which is why I have to change.
Currently my doubt is how to change the code to such that my application is able to connect and send messages via Openfire on mobile phone devices ? I had tried searching solution but I couldn't find any. One solution I found in this website was to put the connection part of the code in AsyncTask. Is this true ?
I'm just wondering why doesn't the original server ip address (127.0.0.1) not able to work while my ip address able to work?
127.0.0.1 isn't the server's real IP address. It means localhost, which means whichever computer the code is running on. In other words, the Android application would try to connect to the server on the Android device, but I don't think your OpenFire server is running on the Android device, is it?
I'm new in Azure and I'm having some troubles here. I'm implementing a JAVA server application on my Azure VM. It's listening for requests from an Android client. I have tested the java server app on my machine and it works great. When I run the same java server application on my Azure VM it looks like there are other apps trying to connect through the same port. I have checked and every single time I change the port it happens again (it happens when the firewall is down, when I don't shut down the firewall it doesn't even receive a single request).
I have a message showing when there is a connection through the port 4567 and couple seconds after I start my server app it shows that there is a connection from a similar IP than the one I have assigned and I haven't yet run my android app. I configured the endpoints, and I even shut down the firewall and it is giving the same issue. The client app and the server app are working perfectly if I run the server on my local machine. Help would be really appreciated, thanks in advance.
What you might be seeing is the way Azure manages/monitors public Endpoints. When you expose a public endpoint for your VM Azure will behind the scenes periodically test that port to make sure it is up and listening for traffic. This is part of the way Azure manages load balancing for public Endpoints. Because of this, if you watch connections to your the local port on your VM to which the public endpoint is mapped, you will see connections from Azure internal IPs.