如何将DatagramSocket绑定到Openshift中的特定端口 [英] How to bind DatagramSocket to particular port in Openshift

查看:224
本文介绍了如何将DatagramSocket绑定到Openshift中的特定端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在openshift上运行了简单的Java jar服务,该服务试图与DatagramSocket连接并获取此异常:

I am running siple java jar service on openshift which tried to connect with DatagramSocket and Getting this Exception:

java.net.BindException: Permission denied
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:96)
at java.net.DatagramSocket.bind(DatagramSocket.java:397)
at java.net.DatagramSocket.<init>(DatagramSocket.java:251)
at java.net.DatagramSocket.<init>(DatagramSocket.java:304)
at java.net.DatagramSocket.<init>(DatagramSocket.java:276)
at com.gasmps.service.TerminationListener.run(EmailService.java:542)
at java.lang.Thread.run(Thread.java:745)

我知道这是端口许可问题,但是我尝试使用8000,8443,15005,16005这样的端口,但是变得相同,我该如何解决呢?我怎么知道我可以在我的应用程序中使用的所有开放端口.

I know this is port permission problems but i tried with port like 8000,8443,15005,16005 but getting same how could i resolve this? How i can know all open port that can i use in my application.

我的jboss服务器已经在同一应用程序中运行,并且我不想为这些jar服务bcos创建单独的应用程序,我必须从远程位置从我的应用程序运行此jar.

My jboss server is already running in the same application and I don't want to create separate application for these jar service bcos I have to run this jar from my application from remote location.

推荐答案

在遇到相同问题后,iv对此进行了调查,并在以下方面发现了堆栈溢出的答案:

Iv looked into this before after having the same issue and discovered the answer on stack-overflow before:

在Openshift中,您只能绑定到服务器分配的端口 为你.通常,这是环境变量的值 $ OPENSHIFT_JBOSS_PORT(因盒带而异)和值 齿轮之间有所不同.绑定到任何其他端口将报告为 SELinux政策违规并被拒绝. 链接 端口通常为8080

In Openshift, you may only bind to the port that the server allocates for you. Typically that is the value of the environment variable $OPENSHIFT_JBOSS_PORT (it varies between cartridges) and the value differs between gears. Binding to any other port will be reported as an SELinux policy violation and denied. link The port is usually 8080

您可以将您的应用绑定到8080(而不是8000或8443),在8000和8443上接收到的所有流量都将由代理路由到您的应用>在8080上监听.

you can bind your app to 8080 (not to 8000 or 8443), all traffic >received on 8000 and 8443 will be routed by the proxy to your app >listening on 8080.

这对我有用,但是请让我知道它的运行方式,如果仍然无法运行,我会尽力帮助.

This worked for me, but let me know how it goes and if it still doesn't work i'll try and help.

这篇关于如何将DatagramSocket绑定到Openshift中的特定端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆