springcloud网关服务和message微服务都配置了ssl,结果网关服务路由不到message服务,怎么处理?

springcloud+eureka+网关服务(zuul构建)+ message微服务(微信小程序用到了websocket调用此服务中的接口,需配置ssl)

message微服务中相关代码如下:

application.properties 配置文件代码

server.port=9007  
spring.application.name=message-service 
// https配置
 https.port=443  
server.ssl.key-store=classpath:aliyun.pfx  
server.ssl.key-store-password=8vwAq72s  
server.ssl.key-store-type=PKCS12
// 启动入口代码  
public class MessageServiceApplication {

    public static ConfigurableApplicationContext context = null;

    @Value("${server.port}")
    private Integer httpPort;

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {  

                if (container instanceof TomcatEmbeddedServletContainerFactory) {  
                   TomcatEmbeddedServletContainerFactory containerFactory =
                            (TomcatEmbeddedServletContainerFactory) container;  

                    Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
                    connector.setPort(httpPort);
                    containerFactory.addAdditionalTomcatConnectors(connector);
                }
            }
        };
    }

    public static void main(String[] args) {
            // ...
        }

}

我目前在message微服务里添加了同时支持http和https代码,想法是:网关走http,websocket走https

以上代码:打印信息

2019-06-22 13:42:56.009 [DiscoveryClient-InstanceInfoReplicator-0] INFO  [com.netflix.discovery.DiscoveryClient:804] [,] - DiscoveryClient_MESSAGE-SERVICE/message-service:192.168.60.92:9007 - registrati
on status: 204
2019-06-22 13:42:56.694 [main] INFO  [org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration$HystrixMetricsPollerConfiguration:138] [,] - Starting poller
2019-06-22 13:42:57.101 [SimpleAsyncTaskExecutor-1] INFO  [org.springframework.amqp.rabbit.connection.CachingConnectionFactory:360] [,] - Created new connection: rabbitConnectionFactory#73f79b74:0/Simpl
eConnection@790ff004 [delegate=amqp://guest@127.0.0.1:5672/, localPort= 49865]
2019-06-22 13:42:57.320 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol:179] [,] - Initializing ProtocolHandler ["https-jsse-nio-9007"]
2019-06-22 13:42:57.380 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol:179] [,] - Starting ProtocolHandler ["https-jsse-nio-9007"]
2019-06-22 13:42:58.714 [main] INFO  [org.apache.tomcat.util.net.NioSelectorPool:179] [,] - Using a shared selector for servlet write/read
2019-06-22 13:42:58.749 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol:179] [,] - Initializing ProtocolHandler ["http-nio-9007"]
2019-06-22 13:42:58.752 [main] ERROR [org.apache.coyote.http11.Http11NioProtocol:181] [,] - Failed to initialize end point associated with ProtocolHandler ["http-nio-9007"]
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method) ~[?:1.8.0_111]
        at sun.nio.ch.Net.bind(Net.java:433) ~[?:1.8.0_111]

请教各位大佬,怎么更优雅、简洁地解决小弟难题呢?请赐教,不胜感激!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问