开发者

Bind Jetty to IPv6 address

I am trying to bind Jetty to listen only to IPv6 address. I am using Jetty 7.4.2.v20110526.

my jetty.xml:

<Call name="addConnector">
  <Arg>
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="host">::1</Set>
  开发者_运维问答      <Set name="port"><SystemProperty name="jetty.port" default="8070"/></Set>
        <Set name="maxIdleTime">30000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="confidentialPort">8443</Set>
      </New>
  </Arg>
</Call>    

the error I get:

java.net.SocketException@3d3c4c09: Address family not supported by protocol family: bind; 
at sun.nio.ch.Net.bind(Native Method)
java.net.SocketException: Address family not supported by protocol family: bind
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:172)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:297)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:250)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
at org.eclipse.jetty.server.Server.doStart(Server.java:269)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)

I have tried both ::1 and [::1]

How can I bind Jetty to IPv6 address? Is IPv6 supported by Jetty at all?


If you haven't found a solution, here it is. Change the NIO connector with the IO one. Instead of using "org.mortbay.jetty.nio.SelectChannelConnector" use "org.mortbay.jetty.bio.SocketConnector" and the overall connector config will be:

<Call name="addConnector">
  <Arg>
      <New class="org.mortbay.jetty.bio.SocketConnector">
        <Set name="port"><SystemProperty name="jetty.port" default="8070"/></Set>
        <Set name="maxIdleTime">50000</Set>
        <Set name="lowResourceMaxIdleTime">1500</Set>
      </New>
  </Arg>
</Call>

This way you will be able to access the webpage using both IPv4 and IPv6 address. Hope this helps.


Old versions of the Sun JRE do not support IPv6 on NIO channels, so simply upgrade the JVM.

http://bugs.sun.com/view_bug.do?bug_id=6230761

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜