You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/07/18 15:32:37 UTC

[GitHub] ralf0131 commented on issue #160: server="servlet" 时不能同时发布hessian和webservice协议

ralf0131 commented on issue #160: server="servlet" 时不能同时发布hessian和webservice协议
URL: https://github.com/apache/incubator-dubbo/issues/160#issuecomment-405973813
 
 
   > 比如使用tomcat发布服务, 端口为8080,同时发布为hessian和webservcie时,只能有一个发布成功。
   
   That is true, and the second protocol will fail.
   
   > DispatcherServlet中的 handlers 中指定一个端口只能绑定一个 HttpHandler 。 这种针对 server="jetty"时是没问题的,会启动几个jetty实例。 但是针对是tomcat这种,是不是就不太合理了?
   
   This is not true, no matter what the server is, jetty or tomcat, only the first protocol will be used.
   
   Example:
   
   ```xml
   <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
          xmlns="http://www.springframework.org/schema/beans"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
          http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
   
       <dubbo:application name="demo-provider"/>
       <dubbo:registry address="multicast://224.5.6.7:1234"/>
       <dubbo:protocol name="hessian" port="20880" server="jetty"/>
       <dubbo:protocol name="webservice" port="20880" server="jetty"/>
       <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
       <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService" protocol="hessian,webservice"/>
   
   </beans>
   ```
   
   The second webservice protocol will fail because of the port conflict.
   
   ```
   2018-07-18 23:27:15.799:WARN::failed Server@7cf7aee: java.net.BindException: Address already in use
   Exception in thread "main" java.lang.IllegalStateException: Failed to start jetty server on 192.168.31.235:20880, cause: Address already in use
   	at org.apache.dubbo.remoting.http.jetty.JettyHttpServer.<init>(JettyHttpServer.java:89)
   	at org.apache.dubbo.remoting.http.jetty.JettyHttpBinder.bind(JettyHttpBinder.java:31)
   	at org.apache.dubbo.remoting.http.HttpBinder$Adaptive.bind(HttpBinder$Adaptive.java)
   	at org.apache.dubbo.rpc.protocol.webservice.WebServiceProtocol.doExport(WebServiceProtocol.java:85)
   	at org.apache.dubbo.rpc.protocol.AbstractProxyProtocol.export(AbstractProxyProtocol.java:71)
   	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:57)
   	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:100)
   	at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:170)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:133)
   	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:55)
   	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:98)
   	at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
   	at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:513)
   	at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:358)
   	at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:317)
   	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:216)
   	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:123)
   	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:49)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
   	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
   	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
   	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
   	at org.apache.dubbo.demo.provider.Provider.main(Provider.java:27)
   Caused by: java.net.BindException: Address already in use
   	at java.base/sun.nio.ch.Net.bind0(Native Method)
   	at java.base/sun.nio.ch.Net.bind(Net.java:433)
   	at java.base/sun.nio.ch.Net.bind(Net.java:425)
   	at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:225)
   	at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
   	at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:216)
   	at org.mortbay.jetty.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:315)
   	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
   	at org.mortbay.jetty.Server.doStart(Server.java:235)
   	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
   	at org.apache.dubbo.remoting.http.jetty.JettyHttpServer.<init>(JettyHttpServer.java:86)
   	... 28 more
   ```
   
   ### Conclusion
   
   If you would like to have 2 different protocols, you have to specify two different ports.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org