Облачный шлюз Sping null route - PullRequest
0 голосов
/ 03 февраля 2019

У меня есть среда MicroService, работающая локально с пружиной (2.1.2.RELEASE) и облаком (2.1.0.Release). Я хотел подключить приложение NodeJs к Eureka, чтобы шлюз мог также обслуживать трафик для этой службы.Регистрация на сервере Eureka происходит нормально, но Spring Gateway не разрешает адрес, поэтому он может пересылать трафик.Любая помощь приветствуется

Сервер Spring Eureka (с @EnableEurekaServer)

spring.application.name=eurekaserver
server.port=8761
eureka.instance.hostname=eureka
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
logging.level.root=INFO

Конфигурация приложения Spring Eureka Discovery.Конфигурация регистрации Eureka Я использую eureka-js-client

const eurekaIP = '127.0.0.1';
const eurekaPort=8761;
const client = new Eureka({
    // application instance information
    instance: {
        app: 'nodeFileService',
        instanceId:'nodeFileServ',
        hostName: 'localhost',
        ipAddr: '127.0.0.1',
        port: {
            '$': 3000,
            '@enabled': true,
        },
        statusPageUrl: 'http://localhost:3000',
        vipAddress: 'jq.test.something.com',
        dataCenterInfo: {
            '@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
            name: 'MyOwn',
        },
    },
    eureka: {
        // eureka server host / port
        host: eurekaIP,
        port: eurekaPort,
        servicePath: '/eureka/apps/'
    },
});

client.start((error) => {
    console.log(error || 'complete');
});

Информация о сервере Eureka

<applications>
<versions__delta>1</versions__delta>
<apps__hashcode>UP_2_</apps__hashcode>
<application>
<name>MICROSERVICEDISCOVERY</name>
<instance><instanceId>192.168.1.6:microservicediscovery:8080</instanceId><hostName>192.168.1.6</hostName>
<app>MICROSERVICEDISCOVERY</app>
<ipAddr>192.168.1.6</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">8080</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo><leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1549193491706</registrationTimestamp>
<lastRenewalTimestamp>1549194421787</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1549193491706</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>8080</management.port>
<jmx.port>14883</jmx.port>
</metadata>
<homePageUrl>http://192.168.1.6:8080/</homePageUrl>
<statusPageUrl>http://192.168.1.6:8080/actuator/info</statusPageUrl>
<healthCheckUrl>http://192.168.1.6:8080/actuator/health</healthCheckUrl>
<vipAddress>microservicediscovery</vipAddress>
<secureVipAddress>microservicediscovery</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1549193491707</lastUpdatedTimestamp>
<lastDirtyTimestamp>1549193491625</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
<application>
<name>NODEFILESERVICE</name>
<instance>
<instanceId>nodeFileServ</instanceId>
<hostName>localhost</hostName>
<app>NODEFILESERVICE</app>
<ipAddr>127.0.0.1</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">3000</port>
<securePort enabled="false">7002</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1549193510612</registrationTimestamp>
<lastRenewalTimestamp>1549194440639</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1549193510612</serviceUpTimestamp>
</leaseInfo><metadata class="java.util.Collections$EmptyMap"/>
<statusPageUrl>http://localhost:3000</statusPageUrl>
<vipAddress>jq.test.something.com</vipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1549193510612</lastUpdatedTimestamp>
<lastDirtyTimestamp>1549193510611</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>

И журнал ошибки, с которой я сталкиваюсь

2019-02-03 12:55:01.945 DEBUG 11960 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : The total number of all instances in the client now is 2
2019-02-03 12:55:01.945 DEBUG 11960 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient    : Completed cache refresh task for discovery. All Apps hash code is Local region apps hashcode: UP_2_, is fetching remote regions? false 
2019-02-03 12:55:01.953 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition CompositeDiscoveryClient_MICROSERVICEDISCOVERY applying {pattern=/MICROSERVICEDISCOVERY/**} to Path
2019-02-03 12:55:01.961 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition CompositeDiscoveryClient_MICROSERVICEDISCOVERY applying filter {regexp=/MICROSERVICEDISCOVERY/(?<remaining>.*), replacement=/${remaining}} to RewritePath
2019-02-03 12:55:01.963 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.r.RouteDefinitionRouteLocator    : RouteDefinition matched: CompositeDiscoveryClient_MICROSERVICEDISCOVERY
2019-02-03 12:55:01.964 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.h.RoutePredicateHandlerMapping   : Route matched: 5ab9d11a-2260-48dd-8fdd-05c8330e22a2
2019-02-03 12:55:01.964 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.h.RoutePredicateHandlerMapping   : Mapping [Exchange: GET http://127.0.0.1:8080/test] to Route{id='5ab9d11a-2260-48dd-8fdd-05c8330e22a2', uri=lb://nodeFileService, order=0, predicate=org.springframework.cloud.gateway.support.ServerWebExchangeUtils$$Lambda$393/0x000000080044bc40@71ce009e, gatewayFilters=[OrderedGatewayFilter{delegate=null, order=0}]}
2019-02-03 12:55:01.965 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.h.RoutePredicateHandlerMapping   : [9c8ad71a] Mapped to org.springframework.cloud.gateway.handler.FilteringWebHandler@1ea4f200
2019-02-03 12:55:01.965 DEBUG 11960 --- [ctor-http-nio-3] o.s.c.g.handler.FilteringWebHandler      : Sorted gatewayFilterFactories: [OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@7c5d1d25}, order=-2147482648}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@16736040}, order=-1}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardPathFilter@32eae6f2}, order=0}, OrderedGatewayFilter{delegate=null, order=0}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@550e9be6}, order=10000}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@10272bbb}, order=10100}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@26ca61bf}, order=2147483646}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.NettyRoutingFilter@36d33f4}, order=2147483647}, OrderedGatewayFilter{delegate=GatewayFilterAdapter{delegate=org.springframework.cloud.gateway.filter.ForwardRoutingFilter@3f96f020}, order=2147483647}]
2019-02-03 12:55:01.967 DEBUG 11960 --- [ctor-http-nio-3] .a.w.r.e.DefaultErrorWebExceptionHandler : [9c8ad71a] Resolved [NullPointerException: null] for HTTP GET /test
2019-02-03 12:55:01.967 DEBUG 11960 --- [ctor-http-nio-3] o.s.core.codec.CharSequenceEncoder       : [9c8ad71a] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you  (truncated)...
2019-02-03 12:55:01.967 DEBUG 11960 --- [ctor-http-nio-3] r.n.channel.ChannelOperationsHandler     : [id: 0x9c8ad71a, L:/127.0.0.1:8080 - R:/127.0.0.1:1270] Writing object DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Content-Length: 281
...