Block terminated with an error

#block terminated with an error with Eureka and Micronaut 3.0.0-SNAPSHOT #5882 Comments The GraalVM test application for discovery-client Eureka fails in JIT mode (and also as native image). The error doesn’t happens all the time and I’ve only been able to reproduce it using JDK 11. Sometimes I start the application, send the curl […]

Содержание

  1. #block terminated with an error with Eureka and Micronaut 3.0.0-SNAPSHOT #5882
  2. Comments
  3. Steps to Reproduce
  4. Expected Behaviour
  5. Actual Behaviour
  6. Environment Information
  7. Spring Blog
  8. Flight of the Flux 2 — Debugging Caveats
  9. Debugging in a Reactive World
  10. Demonstrating the issue with vanilla async code
  11. Demonstrating the issue in Reactor
  12. Making Things Better
  13. Back to classics: log
  14. Enriching stacktraces with Debug Mode
  15. Bringing the cost down with checkpoint
  16. Conclusion
  17. Unable to start Netty (TimeoutException) #9905
  18. Comments
  19. AssemblySnapshotException without details #1001
  20. Comments

#block terminated with an error with Eureka and Micronaut 3.0.0-SNAPSHOT #5882

The GraalVM test application for discovery-client Eureka fails in JIT mode (and also as native image).

The error doesn’t happens all the time and I’ve only been able to reproduce it using JDK 11. Sometimes I start the application, send the curl request and it fails. Other times I start the application, wait a few seconds and then send the curl request.

Another thing I do to reproduce the error is deleting all local 3.0.0-SNAPSHOT artifacts (for both core and discovery-client) and then run the application.

Steps to Reproduce

  • git clone https://github.com/micronaut-graal-tests/micronaut-service-discovery-eureka
  • cd micronaut-service-discovery-eureka
  • git checkout error-micronaut3
  • docker run -it —rm -p 8761:8761 registry.gitlab.com/micronaut-projects/micronaut-graal-tests/eureka-server
  • Use Java 11
  • ./gradlew run
  • curl localhost:8080/api/hello/Micronaut

Expected Behaviour

The application should return Hello Micronaut

Actual Behaviour

Environment Information

  • Operating System: Linux Mint 20.1
  • Micronaut Version: 3.0.0-SNAPSHOT
  • JDK Version: 11

The text was updated successfully, but these errors were encountered:

Источник

Spring Blog

Flight of the Flux 2 — Debugging Caveats

This blog post is the second in a series of posts that aim at providing a deeper look into Reactor’s more advanced concepts and inner workings.

It is derived from my Flight of the Flux talk, which content I found to be more adapted to a blog post format.

I’ll update the table below with links when the other posts are published, but here is the planned content:

  1. Assembly vs Subscription
  2. Debugging caveats (this post)
  3. Hopping Threads and Schedulers
  4. Inner workings: work stealing
  5. Inner workings: operator fusion

If you’re missing an introduction to Reactive Streams and the basic concepts of Reactor, head out to the site’s learning section and the reference guide.

Without further ado, let’s jump in:

Debugging in a Reactive World

Switching from an imperative, blocking paradigm to a reactive, non-blocking one brings benefits but also comes with some caveats. One of these is the debugging experience. Why is that?

Primarily because you’ve learned to rely on the good old stacktrace, but suddenly this invaluable tool becomes far less valuable due to the asynchronous aspect of reactive programming. This is not specific to reactive programming though: as soon as you introduce asynchronous code, you create a boundary in the program between the code that schedules and the code that asynchronously executes.

Demonstrating the issue with vanilla async code

Let’s take an example with an ExecutorService and a Future (no Reactor code here):

This example is a bit contrived, but let’s imagine that we have these two out of three path in the code that can lead to the asynchronous task throwing an IndexOutOfBoundsException … How helpful would the stacktrace be?

  • the Future ’s get() method threw an ExecutionException
  • the cause is an IndexOutOfBoundsException
  • the code throwing is in the submit(() -> source.get(5)) lambda line 76
  • it executed in a FutureTask , from something called a ThreadPoolExecutor , itself running in a Thread …
  • we have two potential sources that could cause this but no idea which one is the culprit (which path was taken in the test prior to calling submit() ).

Not terribly useful 🙁

Demonstrating the issue in Reactor

If we look for a Reactor equivalent to the above code, we can come up with this:

Which triggers the following stacktrace:

  • We see the ArrayIndexOutOfBoundsException again, hinting at a source that was too short for the MonoElementAt operator
  • We see that it came from an onComplete , itself triggered by request … and a bunch of other steps in reactor.core.publisher
  • With a bit of familiarity with these reactor methods, we might deduce that the pipeline was made up of range ( FluxRange.subscribe ), elementAt and subscribeOn …
  • It seems the throwing code was executed from the worker Thread of a ThreadPoolExecutor
  • The trail goes cold here…

Worse, even if we did get rid of subscribeOn we’d still wouldn’t discover which of the two possible error paths was triggered:

Gives the stacktrace:

That is because, as we saw previously, there is an additional “boundary” in code between assembly and subscription. The trail only goes back to the point of subscription (here the block() ) 🙁

So using stacktraces for analysis and debugging purposes is harder in an asynchronous world, and even a bit harder in Reactor (because it is asynchronous and has a lazy-by-default approach with assembly vs subscription). But fortunately there are tools in the library to try and alleviate that fact.

Making Things Better

Back to classics: log

Remember when you sprinkled your imperative code with print statements? It might not be as cool as firing up the step debugger, but sometimes it is the quick and dirty solution you need.

In Reactor, you have the log() operator:

  • It logs Reactive Stream signals: onNext , onComplete , onError (and even onSubscribe , cancel and request !)
  • You can tune it to whitelist only part of these signals
  • You can choose a particular Logger as well

In short, log is the quick and dirty solution to get an easy bird eye’s view of what is going on at one step of your sequence. Use it liberally during development, with the possibility of specifying a “name” to each log call to differentiate them.

Using log(String) can be diverted to get a hint at which source causes the error:

The stacktrace itself isn’t much more interesting (apart from mentioning the MonoLogFuseable class, but the log itself contains this interesting tidbit:

At least we get our hardcoded source C label…

Enriching stacktraces with Debug Mode

Another approach that is available in Reactor is to try and get back the assembly information in the runtime stacktraces.

This can be done by activating the so-called “debug mode” via the Hooks class:

What does it do? It makes each operator instantiation (aka assembly) capture a stacktrace and keep it for later.

If an onError reaches one operator, it will attach that assembly stacktrace to the onError ’s Throwable (as a suppressed Exception ). As a result, when you see the stacktrace you’ll get a more complete picture of both the runtime AND the assembly.

With debug mode on, in our earlier example we would be able to see which assembly path was taken and which source was actually processed:

Which produces the following stacktrace:

Notice the last line? Yay 😀

Bringing the cost down with checkpoint

One drawback of using Hooks.onOperatorDebug() is that it does the assembly stacktrace capture for every single operator used in the application. Filling a single stacktrace is a costly operation, so it goes without saying that this can have an heavy impact on performance. As a result, this is only recommended in a development setting.

Fortunately, you can bring the cost down a little if you identify parts of your codebase that are prone to that sort of source ambiguity.

By using the checkpoint() operator, it is possible to activate the assembly trace capture only at that specific point in the codebase. You can even do entirely without the filling of a stacktrace if you give the checkpoint a unique and meaningful name using checkpoint(String) :

This produces the following stacktrace:

Notice the is identified by light checkpoint [source just(1,2,3,4)]. , which gives us our culprit (because we used a meaningful description for the checkpoint).

Conclusion

In this article, we’ve learned that stacktraces can be less useful in asynchronous programming. This effect is further compounded by the lazy way Reactor let you build reactive sequences.

We’ve looked at the worst cases that can be encountered and at several ways this problem can be lessened.

The whole code can be found in a gist here.

In the next instalment, we’ll learn about schedulers and how to hop from one thread to another.

Источник

Unable to start Netty (TimeoutException) #9905

Issue: Netty is unable to start due to timeout in the latest ‘2.0.0.M3’. In ‘2.0.0.M2’ everything works fine.

[reactor-core-3.1.0.M3.jar:3.1.0.M3] at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:87)

[reactor-core-3.1.0.M3.jar:3.1.0.M3] at reactor.core.publisher.Mono.block(Mono.java:1280)

[reactor-core-3.1.0.M3.jar:3.1.0.M3] at reactor.ipc.netty.tcp.BlockingNettyContext. (BlockingNettyContext.java:55)

[reactor-netty-0.7.0.M1.jar:0.7.0.M1] at reactor.ipc.netty.tcp.BlockingNettyContext. (BlockingNettyContext.java:45)

[reactor-netty-0.7.0.M1.jar:0.7.0.M1] at reactor.ipc.netty.NettyConnector.start(NettyConnector.java:53)

[reactor-netty-0.7.0.M1.jar:0.7.0.M1] at org.springframework.boot.web.embedded.netty.NettyWebServer.start(NettyWebServer.java:64)

[spring-boot-2.0.0.M3.jar:2.0.0.M3] . 10 common frames omitted Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:88)

[reactor-core-3.1.0.M3.jar:3.1.0.M3] . 15 common frames omitted Caused by: java.util.concurrent.TimeoutException: HttpServer couldn’t be started within 3000ms at reactor.ipc.netty.tcp.BlockingNettyContext. (BlockingNettyContext.java:53)

[reactor-netty-0.7.0.M1.jar:0.7.0.M1] . 13 common frames omitted»>

Environment
Kotlin: 1.1.3-2
SpringBoot: 2.0.0.M3
Java: 1.8.0_112 (build 1.8.0_112-b16)

Steps to reproduce
Create a project from Spring Initializr using Spring Boot: 2.0.0 M3 with Reactive Web

The text was updated successfully, but these errors were encountered:

It is not related to https://thoeni.io/post/macos-sierra-java, as my /ect/hosts have the required entries for 127.0.0.0 and ::1 .

Has M2 worked successfully since you experienced this problem with M3?

Yes, I am using M2 currently and it is running successfully.

@ganesshkumar I can’t recreate this so it’s either specific to your environment or there’s more to it than you’ve described. To eliminate the latter, can you please provide a minimal sample that reproduces the problem?

Here is the repo I just created using Spring Initializr.

I have added the complete stack track in README. Let me know if you want more details.

Thanks for the sample. It starts fine for me via both bootRun and java -jar so it would appear that the problem is in some way specific to your environment.

Can you please try running with logging.level.root=debug so that we can see what’s going on during startup? A thread dump taken towards the end of the 5 second period while it waits for Netty to start may also be informative.

I have the same issue too. In both my Macbook pro and dell xps 13(arch linux).

This is log with logging.level.root=debug :
artemis.log.zip

@wilkinsona I have updated the logs in the repo.

Log via gradle task by running ./gradlew bootRun —debug

Log via application.properties by adding logging.level.root=debug in application.properties

Thank you, @ganesshkumar. In both cases there’s a

5 second gap between these two lines:

On my machine that gap is less than 30ms:

Interestingly, a call to InetAddress.getLocalHost() is made between those two lines being logged. The stack trace is:

I know you said above that you do not believe that it’s related to InetAddress.getLocalHost() , but I suspect that it may well be. How long does a call to InetAddress.getLocalHost() take on your machine? If it’s quick and my suspicion is wrong, I think we’ll need a thread dump during the 5 second window after the first line has been logged to make further progress.

I follow this solution then it work now.

@hendisantika We don’t know exactly what the problem is just yet. We still need some more information, specifically:

How long does a call to InetAddress.getLocalHost() take on your machine? If it’s quick and my suspicion is wrong, I think we’ll need a thread dump during the 5 second window after the first line has been logged to make further progress.

Sorry for delayed update.

After updating to macOS Sierra 10.12.6, everything is working fine as expected.

@hendisantika, just double check you have the hostname as third field in /etc/hosts file.

I have faced this issue around M2. I had both the entries but the missing hostname field made InetAddress.getLocalHost() to take more than 3s.

My mac already used macOS Sierra 10.12.6 and I already followed the /etc/host too @ganesshkumar. But, I still got the issue.

Should I post the repo so that anyone can test it?

I am facing the same issue for 2.0.0.M3 while it works fine for 2.0.0.M2

we are still waiting for a sample. Can you please share one?

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-issuemaster and the others member like @mohitsinha or @ganesshkumar can try my repo to see if it works on your machine.

BTW, I already follow the /etc/host but it still got error.

Источник

AssemblySnapshotException without details #1001

We try to retrieve app and service usage events of some larger CF installations and receive the following exceptions:

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1730)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1680)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.tokenprovider.AbstractUaaTokenProvider.token(AbstractUaaTokenProvider.java:272)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

[na:1.8.0_212] at org.cloudfoundry.reactor.tokenprovider.AbstractUaaTokenProvider.getToken(AbstractUaaTokenProvider.java:108)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at org.cloudfoundry.reactor.util.AbstractReactorOperations.addAuthorization(AbstractReactorOperations.java:258)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at reactor.core.publisher.Mono.transform(Mono.java:4093)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.util.AbstractReactorOperations.lambda$null$4(AbstractReactorOperations.java:103)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at reactor.ipc.netty.http.client.HttpClient.lambda$handler$4(HttpClient.java:429)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.MonoHttpClientResponse$HttpClientHandler.apply(MonoHttpClientResponse.java:121)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.MonoHttpClientResponse$HttpClientHandler.apply(MonoHttpClientResponse.java:84)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:380)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.HttpClientOperations.onHandlerStart(HttpClientOperations.java:505)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:446)

[netty-transport-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at java.lang.Thread.run(Thread.java:748)

[na:1.8.0_212] Suppressed: reactor.core.publisher.FluxOnAssembly$AssemblySnapshotException: null at reactor.core.publisher.MonoOnAssembly. (MonoOnAssembly.java:62)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1730)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1680)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.client.v2.serviceusageevents.ReactorServiceUsageEvents.list(ReactorServiceUsageEvents.java:55)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:93)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.block(Mono.java:1493)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] . Suppressed: reactor.core.publisher.FluxOnAssembly$AssemblySnapshotException: null at reactor.core.publisher.MonoOnAssembly. (MonoOnAssembly.java:62)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1730)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1680)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.tokenprovider.AbstractUaaTokenProvider.token(AbstractUaaTokenProvider.java:272)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

[na:1.8.0_212] at org.cloudfoundry.reactor.tokenprovider.AbstractUaaTokenProvider.getToken(AbstractUaaTokenProvider.java:108)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at org.cloudfoundry.reactor.util.AbstractReactorOperations.addAuthorization(AbstractReactorOperations.java:258)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at reactor.core.publisher.Mono.transform(Mono.java:4093)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.util.AbstractReactorOperations.lambda$null$4(AbstractReactorOperations.java:103)

[cloudfoundry-client-reactor-3.15.0.RELEASE.jar!/:na] at reactor.ipc.netty.http.client.HttpClient.lambda$handler$4(HttpClient.java:429)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.MonoHttpClientResponse$HttpClientHandler.apply(MonoHttpClientResponse.java:121)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.MonoHttpClientResponse$HttpClientHandler.apply(MonoHttpClientResponse.java:84)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:380)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at reactor.ipc.netty.http.client.HttpClientOperations.onHandlerStart(HttpClientOperations.java:505)

[reactor-netty-0.7.9.RELEASE.jar!/:0.7.9.RELEASE] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:446)

[netty-transport-4.1.29.Final.jar!/:4.1.29.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)

[netty-common-4.1.29.Final.jar!/:4.1.29.Final] at java.lang.Thread.run(Thread.java:748)

[na:1.8.0_212] Suppressed: reactor.core.publisher.FluxOnAssembly$AssemblySnapshotException: null at reactor.core.publisher.MonoOnAssembly. (MonoOnAssembly.java:62)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1730)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at reactor.core.publisher.Mono.checkpoint(Mono.java:1680)

[reactor-core-3.2.3.RELEASE.jar!/:3.2.3.RELEASE] at org.cloudfoundry.reactor.client.v2.applicationusageevents.ReactorApplicationUsageEvents.list(ReactorApplicationUsageEvents.java:55)

The exceptions don’t contain much valuable information besides «Something went wrong» during the call. Can you provide any hints on what might be going here? Perhaps error handling should also be enhanced in cf-client?

Some more details about what we do is, that we collect the usage events every 30 minutes. We noticed, that the call works the first time, but further calls always run into this issue. The stacktrace is also very large, as the mentioned blocks of the stacktrace appear like a hundred times.

The text was updated successfully, but these errors were encountered:

Источник

i am using spring web flux, web client to call a rest api. i am getting the following error.

Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: java.lang.Exception: #block terminated with an error 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[reactor-core-3.3.2.RELEASE.jar!/:3.3.2.RELEASE] 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      ... 97 common frames omitted 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:  
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Error has been observed at the following site(s): 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  |_ checkpoint ? Request to GET https://cc-qa.app/api/matches/list/?status=current&page=0&size=100 [DefaultWebClient] 

is the problem with my web client call or the api i am calling ?
i am confused as it showing many error like Connection rest by peers,#block terminated with an error.Error has been observed at the following site.
how to solve this ?
please find the code below

  @Bean
  public WebClient restClient() {

    String baseurl = env.getProperty("base-url");
    int memoryLimit = Integer.parseInt(env.getProperty("webclient-buffer-size"));

    ExchangeStrategies exchangeStrategies =
        ExchangeStrategies.builder()
            .codecs(
                configurer -> configurer.defaultCodecs().maxInMemorySize(1024 * 1024 * memoryLimit))
            .build();
    return WebClient.builder()
        .exchangeStrategies(exchangeStrategies)
        .baseUrl(baseurl)
        .build();
  }

this the api call:

webClient
              .get()
              .uri("/api/matches/list/?status=current&page=0&size=100")
              .header("authorization", accessToken)
              .retrieve()
              .bodyToMono(InfoPayload.class)
              .block();

please help me to find the issue . thanks in advance

The GraalVM test application for discovery-client Eureka fails in JIT mode (and also as native image).

The error doesn’t happens all the time and I’ve only been able to reproduce it using JDK 11. Sometimes I start the application, send the curl request and it fails. Other times I start the application, wait a few seconds and then send the curl request.

Another thing I do to reproduce the error is deleting all local 3.0.0-SNAPSHOT artifacts (for both core and discovery-client) and then run the application.

Steps to Reproduce

  • git clone https://github.com/micronaut-graal-tests/micronaut-service-discovery-eureka
  • cd micronaut-service-discovery-eureka
  • git checkout error-micronaut3
  • docker run -it --rm -p 8761:8761 registry.gitlab.com/micronaut-projects/micronaut-graal-tests/eureka-server
  • Use Java 11
  • ./gradlew run
  • curl localhost:8080/api/hello/Micronaut

Expected Behaviour

The application should return Hello Micronaut

Actual Behaviour

 __  __ _                                  _   
|  /  (_) ___ _ __ ___  _ __   __ _ _   _| |_ 
| |/| | |/ __| '__/ _ | '_  / _` | | | | __|
| |  | | | (__| | | (_) | | | | (_| | |_| | |_ 
|_|  |_|_|___|_|  ___/|_| |_|__,_|__,_|__|
  Micronaut (v3.0.0-SNAPSHOT)

10:02:31.932 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 941ms. Server Running: http://localhost:8080
10:02:32.013 [default-nioEventLoopGroup-1-2] DEBUG i.m.h.client.netty.DefaultHttpClient - Sending HTTP POST to http://localhost:8761/eureka/apps/service-discovery-eureka
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Content-Type: application/json
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Accept: application/json
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - host: localhost:8761
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - connection: close
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 762
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Request Body
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - {"instance":{"instanceId":"service-discovery-eureka:8080","app":"service-discovery-eureka","ipAddr":"127.0.0.1","port":{"@enabled":true,"$":8080},"securePort":{"@enabled":false,"$":0},"homePageUrl":"http://localhost:8080","statusPageUrl":"http://localhost:8080/health","healthCheckUrl":"http://localhost:8080/health","secureHealthCheckUrl":"https://localhost/health","vipAddress":"service-discovery-eureka","secureVipAddress":"service-discovery-eureka","countryId":1,"dataCenterInfo":{"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","name":"MyOwn"},"hostName":"localhost","status":"UP","leaseInfo":{"renewalIntervalInSecs":30,"durationInSecs":90,"registrationTimestamp":0,"lastRenewalTimestamp":0,"evictionTimestamp":0,"serviceUpTimestamp":0}}}
10:02:32.015 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:32.032 [default-nioEventLoopGroup-1-2] DEBUG i.m.h.client.netty.DefaultHttpClient - Received response 204 from http://localhost:8761/eureka/apps/service-discovery-eureka
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Content-Type: application/json
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Date: Mon, 26 Jul 2021 08:02:32 GMT
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Connection: close
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - Response Body
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - 
10:02:32.032 [default-nioEventLoopGroup-1-2] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:32.034 [default-nioEventLoopGroup-1-2] INFO  i.m.d.registration.AutoRegistration - Registered service [service-discovery-eureka] with Eureka
10:02:35.038 [default-nioEventLoopGroup-1-4] DEBUG i.m.h.client.netty.DefaultHttpClient - Sending HTTP GET to http://localhost:8761/eureka/apps/service-discovery-eureka
10:02:35.038 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Accept: application/json
10:02:35.038 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - host: localhost:8761
10:02:35.038 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - connection: close
10:02:35.045 [default-nioEventLoopGroup-1-4] DEBUG i.m.h.client.netty.DefaultHttpClient - Received response 404 from http://localhost:8761/eureka/apps/service-discovery-eureka
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Content-Type: application/json
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Date: Mon, 26 Jul 2021 08:02:35 GMT
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Connection: close
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 0
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Response Body
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - 
10:02:35.046 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:35.047 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Full HTTP response received an empty body
10:02:35.047 [default-nioEventLoopGroup-1-4] TRACE i.m.h.client.netty.DefaultHttpClient - Unable to convert response body to target type class io.micronaut.http.hateoas.JsonError
10:02:35.049 [default-nioEventLoopGroup-1-3] ERROR i.m.r.intercept.RecoveryInterceptor - Type [example.micronaut.HelloClient$Intercepted] attempting to resolve fallback for unavailable service [service-discovery-eureka]
10:02:35.056 [default-nioEventLoopGroup-1-3] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: No available services for ID: service-discovery-eureka
io.micronaut.discovery.exceptions.NoAvailableServiceException: No available services for ID: service-discovery-eureka
        at io.micronaut.http.client.loadbalance.AbstractRoundRobinLoadBalancer.getNextAvailable(AbstractRoundRobinLoadBalancer.java:50)
        at io.micronaut.core.async.publisher.Publishers$1.doOnNext(Publishers.java:214)
        at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onNext(CompletionAwareSubscriber.java:52)
        at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
        at reactor.core.publisher.MonoReduceSeed$ReduceSeedSubscriber.onComplete(MonoReduceSeed.java:165)
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058)
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058)
        at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2400)
        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2194)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onSubscribe(FluxOnErrorResume.java:74)
        at reactor.core.publisher.FluxJust.subscribe(FluxJust.java:68)
        at reactor.core.publisher.Flux.subscribe(Flux.java:8402)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
        at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106)
        at reactor.core.publisher.Operators.error(Operators.java:198)
        at reactor.core.publisher.FluxError.subscribe(FluxError.java:43)
        at reactor.core.publisher.Flux.subscribe(Flux.java:8402)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
        at io.micronaut.core.async.publisher.Publishers$1.doOnError(Publishers.java:225)
        at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onError(CompletionAwareSubscriber.java:63)
        at reactor.core.publisher.StrictSubscriber.onError(StrictSubscriber.java:106)
        at reactor.core.publisher.FluxSwitchMap$SwitchMapMain.checkTerminated(FluxSwitchMap.java:391)
        at reactor.core.publisher.FluxSwitchMap$SwitchMapMain.drain(FluxSwitchMap.java:338)
        at reactor.core.publisher.FluxSwitchMap$SwitchMapMain.innerError(FluxSwitchMap.java:424)
        at reactor.core.publisher.FluxSwitchMap$SwitchMapInner.onError(FluxSwitchMap.java:517)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106)
        at reactor.core.publisher.Operators.error(Operators.java:198)
        at reactor.core.publisher.FluxError.subscribe(FluxError.java:43)
        at reactor.core.publisher.Flux.subscribe(Flux.java:8402)
        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
        at reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124)
        at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.onError(FluxTimeout.java:219)
        at io.micronaut.http.client.filters.ClientServerRequestTracingPublisher$1.lambda$onError$2(ClientServerRequestTracingPublisher.java:65)
        at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:68)
        at io.micronaut.http.client.filters.ClientServerRequestTracingPublisher$1.onError(ClientServerRequestTracingPublisher.java:65)
        at reactor.core.publisher.StrictSubscriber.onError(StrictSubscriber.java:106)
        at reactor.core.publisher.FluxCreate$BaseSink.error(FluxCreate.java:453)
        at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:230)
        at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
        at reactor.core.publisher.FluxCreate$SerializedFluxSink.error(FluxCreate.java:182)
        at io.micronaut.http.client.netty.DefaultHttpClient$11.channelReadInstrumented(DefaultHttpClient.java:2192)
        at io.micronaut.http.client.netty.DefaultHttpClient$11.channelReadInstrumented(DefaultHttpClient.java:2098)
        at io.micronaut.http.client.netty.DefaultHttpClient$SimpleChannelInboundHandlerInstrumented.channelRead0(DefaultHttpClient.java:2826)
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:205)
        at io.micronaut.http.netty.stream.HttpStreamsClientHandler.channelRead(HttpStreamsClientHandler.java:189)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
        Suppressed: java.lang.Exception: #block terminated with an error
                at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
                at reactor.core.publisher.Flux.blockFirst(Flux.java:2599)
                at io.micronaut.http.client.netty.DefaultHttpClient$3.exchange(DefaultHttpClient.java:582)
                at io.micronaut.http.client.BlockingHttpClient.retrieve(BlockingHttpClient.java:140)
                at io.micronaut.http.client.interceptor.HttpClientIntroductionAdvice.lambda$intercept$5(HttpClientIntroductionAdvice.java:401)
                at io.micronaut.http.client.interceptor.HttpClientIntroductionAdvice.handleBlockingCall(HttpClientIntroductionAdvice.java:501)
                at io.micronaut.http.client.interceptor.HttpClientIntroductionAdvice.intercept(HttpClientIntroductionAdvice.java:400)
                at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:137)
                at io.micronaut.retry.intercept.RecoveryInterceptor.intercept(RecoveryInterceptor.java:92)
                at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:137)
                at example.micronaut.HelloClient$Intercepted.sayHi(Unknown Source)
                at example.micronaut.GatewayController.sayHi(GatewayController.java:17)
                at example.micronaut.$GatewayController$Definition$Exec.dispatch(Unknown Source)
                at io.micronaut.context.AbstractExecutableMethodsDefinition$DispatchedExecutableMethod.invoke(AbstractExecutableMethodsDefinition.java:338)
                at io.micronaut.context.DefaultBeanContext$4.invoke(DefaultBeanContext.java:502)
                at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:303)
                at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:121)
                at io.micronaut.http.server.netty.RoutingInBoundHandler.emitRouteResponse(RoutingInBoundHandler.java:1359)
                at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$createExecuteRoutePublisher$19(RoutingInBoundHandler.java:1330)
                at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
                at reactor.core.publisher.Flux.subscribe(Flux.java:8402)
                at io.micronaut.http.server.netty.RoutingInBoundHandler.handleRouteMatch(RoutingInBoundHandler.java:768)
                at io.micronaut.http.server.netty.RoutingInBoundHandler.channelRead0(RoutingInBoundHandler.java:614)
                at io.micronaut.http.server.netty.RoutingInBoundHandler.channelRead0(RoutingInBoundHandler.java:168)
                at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:102)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.micronaut.http.netty.stream.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:211)
                at io.micronaut.http.netty.stream.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:123)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
                at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
                at io.netty.handler.codec.http.HttpServerKeepAliveHandler.channelRead(HttpServerKeepAliveHandler.java:64)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
                at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
                at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:200)
                at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:162)
                ... 27 common frames omitted
10:02:36.607 [default-nioEventLoopGroup-1-5] DEBUG i.m.h.client.netty.DefaultHttpClient - Sending HTTP PUT to http://localhost:8761/eureka/apps/service-discovery-eureka/service-discovery-eureka%3A8080
10:02:36.607 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - Accept: application/json
10:02:36.607 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - host: localhost:8761
10:02:36.607 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - connection: close
10:02:36.607 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 0
10:02:36.614 [default-nioEventLoopGroup-1-6] DEBUG i.m.h.client.netty.DefaultHttpClient - Sending HTTP PUT to http://localhost:8761/eureka/apps/service-discovery-eureka/service-discovery-eureka%3A8080/status?value=UP
10:02:36.614 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - Accept: application/json
10:02:36.614 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - host: localhost:8761
10:02:36.614 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - connection: close
10:02:36.615 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 0
10:02:36.616 [default-nioEventLoopGroup-1-5] DEBUG i.m.h.client.netty.DefaultHttpClient - Received response 200 from http://localhost:8761/eureka/apps/service-discovery-eureka/service-discovery-eureka%3A8080
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - Content-Type: application/json
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - Date: Mon, 26 Jul 2021 08:02:36 GMT
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - Connection: close
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 0
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - Response Body
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - 
10:02:36.617 [default-nioEventLoopGroup-1-5] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:36.622 [default-nioEventLoopGroup-1-6] DEBUG i.m.h.client.netty.DefaultHttpClient - Received response 200 from http://localhost:8761/eureka/apps/service-discovery-eureka/service-discovery-eureka%3A8080/status?value=UP
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - Content-Type: application/json
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - Date: Mon, 26 Jul 2021 08:02:36 GMT
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - Connection: close
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - content-length: 0
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - Response Body
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - ----
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - 
10:02:36.623 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - ----

Environment Information

  • Operating System: Linux Mint 20.1
  • Micronaut Version: 3.0.0-SNAPSHOT
  • JDK Version: 11

Я изучаю веб-сокеты с помощью Spring 5. Я использую этот учебник. Но когда я пытаюсь подключиться к websocket через JavaScript, у меня возникает следующая ошибка:

WebSocket connection to 'ws://localhost:8080/event-emitter' failed: Error during WebSocket handshake: Unexpected response code: 404

Когда я пытаюсь подключиться к websocket через Java, у меня появляется следующая ошибка:

Exception in thread "main" reactor.ipc.netty.http.client.HttpClientException: HTTP request failed with code: 404.
Failing URI: /event-emitter
Suppressed: java.lang.Exception: #block terminated with an error
    at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:126)
    at reactor.core.publisher.Mono.block(Mono.java:1185)

Мой ReactAndSpringDataRestApplication.java:

@SpringBootApplication
public class ReactAndSpringDataRestApplication {

@Autowired
private ReactiveWebSocketHandler webSocketHandler;

public static void main(String[] args) {
    SpringApplication.run(ReactAndSpringDataRestApplication.class, args);
}

@Bean
public HandlerMapping webSocketHandlerMapping() {
    Map<String, WebSocketHandler> map = new HashMap<>();
    map.put("/event-emitter", webSocketHandler);

    SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
    handlerMapping.setOrder(1);
    handlerMapping.setUrlMap(map);
    return handlerMapping;
}
@Bean
public WebSocketHandlerAdapter handlerAdapter() {
    return new WebSocketHandlerAdapter();
}
}

ReactiveWebSocketHandler.java:

@Component
public class ReactiveWebSocketHandler implements WebSocketHandler {

private static final ObjectMapper json = new ObjectMapper();

private Flux<String> eventFlux = Flux.generate(sink -> {
    EventTwo event = new EventTwo(Double.toString(Math.random()), new Date().toString());
    try {
        sink.next(json.writeValueAsString(event));
    } catch (JsonProcessingException e) {
        sink.error(e);
    }
});
private Flux<String> intervalFlux = Flux.interval(Duration.ofMillis(1000L))
        .zipWith(eventFlux, (time, event) -> event);

@Override
public Mono<Void> handle(WebSocketSession webSocketSession) {
    return webSocketSession.send(intervalFlux
            .map(webSocketSession::textMessage))
            .and(webSocketSession.receive()
                    .map(WebSocketMessage::getPayloadAsText)
                    .log());
}
}

JavaScript, который пытается подключиться к websocket:

import React, {Component} from 'react';
import { connect } from 'react-redux';
import '../res/messages.css';
class Messages extends Component {

constructor(props) {
    super(props);
    this.state = {messages: []};
}

getInitialState(){
    return { messages : [] }
}

componentDidMount() {
    var clientWebSocket = new WebSocket("ws://localhost:8080/event-emitter");
    clientWebSocket.onopen = function() {
        console.info("clientWebSocket.onopen", clientWebSocket);
        console.info("clientWebSocket.readyState", "websocketstatus");
        clientWebSocket.send("event-me-from-browser");
    }
    clientWebSocket.onclose = function(error) {
        console.info("clientWebSocket.onclose", clientWebSocket, error);
    }
    clientWebSocket.onerror = function(error) {
        console.info("clientWebSocket.onerror", clientWebSocket, error);
    }
    clientWebSocket.onmessage = function(error) {
        console.info("clientWebSocket.onmessage", clientWebSocket, error);
        this.setState({
                        messages : this.state.messages.concat([ new Date() ])
                    })
    }
}

render() {
    return (
        <div><ul>{ this.state.messages.map( (msg, idx) => <li key = {'msg-' + idx }>{ msg }</li> )}</ul></div>
    )
}
}

Должна ли быть дополнительная настройка веб-сокетов на стороне Java Spring? Почему клиент не может подключиться к серверу?

Я использую spring web flux, веб-клиент для вызова api отдыха. я получаю следующую ошибку.

Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: java.lang.Exception: #block terminated with an error 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[reactor-core-3.3.2.RELEASE.jar!/:3.3.2.RELEASE] 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8      ... 97 common frames omitted 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:  
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8 Error has been observed at the following site(s): 
Oct 21 09:46:27 ql-hybrid-stg web.7d755d6967-5d7v8  |_ checkpoint ? Request to GET https://cc-qa.app/api/matches/list/?status=current&page=0&size=100 [DefaultWebClient] 

Проблема с вызовом моего веб-клиента или API, который я вызываю? Я сбит с толку, так как он показывает много ошибок, таких как отключение соединения от одноранговых узлов, # блок завершен с ошибкой. Ошибка была обнаружена на следующем сайте. как это решить? пожалуйста, найдите код ниже

  @Bean
  public WebClient restClient() {

    String baseurl = env.getProperty("base-url");
    int memoryLimit = Integer.parseInt(env.getProperty("webclient-buffer-size"));

    ExchangeStrategies exchangeStrategies =
        ExchangeStrategies.builder()
            .codecs(
                configurer -> configurer.defaultCodecs().maxInMemorySize(1024 * 1024 * memoryLimit))
            .build();
    return WebClient.builder()
        .exchangeStrategies(exchangeStrategies)
        .baseUrl(baseurl)
        .build();
  }

Это вызов API:

webClient
              .get()
              .uri("/api/matches/list/?status=current&page=0&size=100")
              .header("authorization", accessToken)
              .retrieve()
              .bodyToMono(InfoPayload.class)
              .block();

Пожалуйста, помогите мне найти проблему. заранее спасибо

2 ответа

Лучший ответ

Проблема решена после добавления клиентского коннектора.

 private ClientHttpConnector connector() {
    return new 
 ReactorClientHttpConnector(HttpClient.create(ConnectionProvider.newConnection()));
  }

WebClient.builder()
        .clientConnector(connector())
        .exchangeStrategies(exchangeStrategies)
        .baseUrl(baseurl)
        .build();


2

raj_kumar_junior
4 Фев 2021 в 10:23

Для меня добавление baseUrl решило проблему. Просто .mutate() существующий экземпляр WebClient/WebTestClient и установите .baseUrl(<>)


0

Anthony Vinay
6 Сен 2022 в 10:47

When using the inheritance feature described in the Cloud Foundry Docs the plugin fails to deploy with 

java.lang.IllegalStateException: Application application-name failed during staging

Full description

We use the inherit `base-manifest.yml` feature mentioned above in our projects, so the manifests look like:

base-manifest.yml
instances: 1
memory: 1G
buildpack: https:path: path.to.jar
manifest.yml
inherit: base-manifest.yml
applications:
  - name: application-name
    timeout : 180
    services:
      - services-to-bind
    env:
      SPRING_PROFILES_ACTIVE: abcdef

But when trying to deploy the application with Jenkins + Cloud Foundry Plugin it fails with the stacktrace shown at the end of this issue.

But when merging the manifest files everything works as expected.

instances: 1
memory: 1G
buildpack: https:path: path.to.jar
applications:
  - name: application-name
    timeout : 180
    services:
      - services-to-bind
    env:
      SPRING_PROFILES_ACTIVE: abcdef

Stacktrace

...
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.120 s
[INFO] Finished at: 2017-10-04T14:42:29+02:00
[INFO] Final Memory: 75M/990M
[INFO] ------------------------------------------------------------------------
Cloud Foundry Plugin:
java.lang.IllegalStateException: Application application-name failed during staging
	at org.cloudfoundry.util.ExceptionUtils.illegalState(ExceptionUtils.java:60)
	at org.cloudfoundry.operations.applications.DefaultApplications.waitForStaging(DefaultApplications.java:1734)
	at org.cloudfoundry.operations.applications.DefaultApplications.lambda$startApplicationAndWait$134(DefaultApplications.java:1503)
	at reactor.core.publisher.MonoThenMap$ThenMapMain.onNext(MonoThenMap.java:120)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:115)
	at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:173)
	at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:235)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.ipc.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:207)
	at reactor.ipc.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:322)
	at reactor.ipc.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:316)
	at reactor.ipc.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:581)
	at reactor.ipc.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:125)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at reactor.ipc.netty.http.HttpOperations.lambda$static$3(HttpOperations.java:261)
	at reactor.ipc.netty.ReactorNetty$ExtractorHandler.channelRead(ReactorNetty.java:328)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1240)
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1041)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at java.lang.Thread.run(Unknown Source)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoIgnoreEmpty] :
	reactor.core.publisher.Mono.checkpoint(Mono.java:1400)
	org.cloudfoundry.operations.applications.DefaultApplications.pushManifest(DefaultApplications.java:390)
	com.hpe.cloudfoundryjenkins.CloudFoundryPushTask.perform(CloudFoundryPushTask.java:168)
	com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher.perform(CloudFoundryPushPublisher.java:130)
	hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
	hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
	hudson.model.Build$BuildExecution.post2(Build.java:186)
	hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
	hudson.model.Run.execute(Run.java:1762)
	hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	hudson.model.ResourceController.execute(ResourceController.java:97)
	hudson.model.Executor.run(Executor.java:419)
Error has been observed by the following operator(s):
	|_	Mono.checkpoint(DefaultApplications.java:390)

java.lang.IllegalStateException: Application application-name failed during staging
	at org.cloudfoundry.util.ExceptionUtils.illegalState(ExceptionUtils.java:60)
	at org.cloudfoundry.operations.applications.DefaultApplications.waitForStaging(DefaultApplications.java:1734)
	at org.cloudfoundry.operations.applications.DefaultApplications.lambda$startApplicationAndWait$134(DefaultApplications.java:1503)
	at reactor.core.publisher.MonoThenMap$ThenMapMain.onNext(MonoThenMap.java:120)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:115)
	at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:173)
	at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:235)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108)
	at reactor.ipc.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:207)
	at reactor.ipc.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:322)
	at reactor.ipc.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:316)
	at reactor.ipc.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:581)
	at reactor.ipc.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:125)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at reactor.ipc.netty.http.HttpOperations.lambda$static$3(HttpOperations.java:261)
	at reactor.ipc.netty.ReactorNetty$ExtractorHandler.channelRead(ReactorNetty.java:328)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1240)
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1041)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at java.lang.Thread.run(Unknown Source)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoIgnoreEmpty] :
	reactor.core.publisher.Mono.checkpoint(Mono.java:1400)
	org.cloudfoundry.operations.applications.DefaultApplications.pushManifest(DefaultApplications.java:390)
	com.hpe.cloudfoundryjenkins.CloudFoundryPushTask.perform(CloudFoundryPushTask.java:168)
	com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher.perform(CloudFoundryPushPublisher.java:130)
	hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
	hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
	hudson.model.Build$BuildExecution.post2(Build.java:186)
	hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
	hudson.model.Run.execute(Run.java:1762)
	hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	hudson.model.ResourceController.execute(ResourceController.java:97)
	hudson.model.Executor.run(Executor.java:419)
Error has been observed by the following operator(s):
	|_	Mono.checkpoint(DefaultApplications.java:390)

	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:86)
		at reactor.core.publisher.Mono.block(Mono.java:1301)
		at com.hpe.cloudfoundryjenkins.CloudFoundryPushTask.perform(CloudFoundryPushTask.java:171)
		at com.hpe.cloudfoundryjenkins.CloudFoundryPushPublisher.perform(CloudFoundryPushPublisher.java:130)
		at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
		at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
		at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
		at hudson.model.Build$BuildExecution.post2(Build.java:186)
		at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
		at hudson.model.Run.execute(Run.java:1762)
		at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
		at hudson.model.ResourceController.execute(ResourceController.java:97)
		at hudson.model.Executor.run(Executor.java:419)
Build step 'Push to Cloud Foundry' marked build as failure
Finished: FAILURE

Я изучаю websockets с помощью Spring 5. Я использую этот учебник. Но когда я пытаюсь подключиться к websocket через JavaScript, у меня есть следующая ошибка:

WebSocket connection to 'ws://localhost:8080/event-emitter' failed: Error during WebSocket handshake: Unexpected response code: 404

Когда я пытаюсь подключиться к websocket через Java, я имею следующую ошибку:

Exception in thread "main" reactor.ipc.netty.http.client.HttpClientException: HTTP request failed with code: 404.
Failing URI: /event-emitter
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:126)
at reactor.core.publisher.Mono.block(Mono.java:1185)

Мой ReactAndSpringDataRestApplication.java:

@SpringBootApplication
public class ReactAndSpringDataRestApplication {

@Autowired
private ReactiveWebSocketHandler webSocketHandler;

public static void main(String[] args) {
SpringApplication.run(ReactAndSpringDataRestApplication.class, args);
}

@Bean
public HandlerMapping webSocketHandlerMapping() {
Map<String, WebSocketHandler> map = new HashMap<>();
map.put("/event-emitter", webSocketHandler);

SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
handlerMapping.setOrder(1);
handlerMapping.setUrlMap(map);
return handlerMapping;
}
@Bean
public WebSocketHandlerAdapter handlerAdapter() {
return new WebSocketHandlerAdapter();
}
}

ReactiveWebSocketHandler.java:

@Component
public class ReactiveWebSocketHandler implements WebSocketHandler {

private static final ObjectMapper json = new ObjectMapper();

private Flux<String> eventFlux = Flux.generate(sink -> {
EventTwo event = new EventTwo(Double.toString(Math.random()), new Date().toString());
try {
sink.next(json.writeValueAsString(event));
} catch (JsonProcessingException e) {
sink.error(e);
}
});
private Flux<String> intervalFlux = Flux.interval(Duration.ofMillis(1000L))
.zipWith(eventFlux, (time, event) -> event);

@Override
public Mono<Void> handle(WebSocketSession webSocketSession) {
return webSocketSession.send(intervalFlux
.map(webSocketSession::textMessage))
.and(webSocketSession.receive()
.map(WebSocketMessage::getPayloadAsText)
.log());
}
}

JavaScript, которые пытаются подключиться к websocket:

import React, {Component} from 'react';
import { connect } from 'react-redux';
import '../res/messages.css';
class Messages extends Component {

constructor(props) {
super(props);
this.state = {messages: []};
}

getInitialState(){
return { messages : [] }
}

componentDidMount() {
var clientWebSocket = new WebSocket("ws://localhost:8080/event-emitter");
clientWebSocket.onopen = function() {
console.log("clientWebSocket.onopen", clientWebSocket);
console.log("clientWebSocket.readyState", "websocketstatus");
clientWebSocket.send("event-me-from-browser");
}
clientWebSocket.onclose = function(error) {
console.log("clientWebSocket.onclose", clientWebSocket, error);
}
clientWebSocket.onerror = function(error) {
console.log("clientWebSocket.onerror", clientWebSocket, error);
}
clientWebSocket.onmessage = function(error) {
console.log("clientWebSocket.onmessage", clientWebSocket, error);
this.setState({
messages : this.state.messages.concat([ new Date() ])
})
}
}

render() {
return (
<div><ul>{ this.state.messages.map( (msg, idx) => <li key={'msg-' + idx }>{ msg }</li> )}</ul></div>
)
}
}

Должна ли быть дополнительная конфигурация веб-сокетов на стороне JavaSpring? Почему клиент не может подключиться к серверу?

Понравилась статья? Поделить с друзьями:
  • Block strike error unknown error
  • Block start at read error abrt
  • Block if without end if как исправить
  • Block error rate
  • Block error amnf victoria что это