質問

I have this following simple scenario:

I have created a JBossAS7 application on OpenShift. I have an index.jsp that calls a Java Class every time it's loaded. This Java class gathers some data and saves it as a string. What I want to do now is get the text contained in that String, but NOT have it displayed on the page.

What I need is a mechanism like RMI or a socket that I can connect to and simply receive the String using a client program. Unfortunately, OpenShift blocks all ports and I cannot use RMI or sockets to bind to anything (I always get permission denied).

Is there a way to solve this? Thanks!

役に立ちましたか?

解決 2

The way I solved this is rather straightforward, but poorly explained and documented on forums or message boards.

OpenShift only allows ports between 15000 and 35530 to be bound by a user. However, when doing so the user must also specify the IP address of the host, otherwise localhost will be used, which is not allowed on OpenShift. The address of the server is located under the environment variable OPENSHIFT_JBOSSAS_IP (I am using JBoss AS 7.1, the variable might have a different name based on whatever technology is used). I found that out by logging into my application via SSH and running the env command.

Once the program is started on OpenShift and the port bound to the correct IP address, the user has to forward the port in order to connect to it. This can be done either from eclipse or using the RHC tools. Port forwarding on OpenShift means that the bound port on the OpenShift server will be mapped to the same port on the localhost of the user. When writing the client program, the user has to connect to localhost:PORT instead of IP_ADDRESS_OF_OPENSHIFT_SERVER:PORT. This was something that took a while for me to understand. Once I got everything right, the client program ran without a problem.

他のヒント

I would say the best way for you to expose that data is through a servlet, or create a restful API and allow access to it, maybe with some authentication or a security token.

Another thought would be to use ironmq (iron.io) and send the data into a queue that you can process from another application.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top