Skip to content

Netty unable to start (timeout) #9741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danielfernandez opened this issue Jul 13, 2017 · 8 comments
Closed

Netty unable to start (timeout) #9741

danielfernandez opened this issue Jul 13, 2017 · 8 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@danielfernandez
Copy link
Contributor

None of my WebFlux-based projects using Spring Boot 2.0.0.BUILD-SNAPSHOT is able to start. When executing mvn -U clean compile spring-boot:run I'm always getting:

[WARNING]
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:499)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start Netty
	at org.springframework.boot.web.embedded.netty.NettyWebServer.start(NettyWebServer.java:65)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.startReactiveWebServer(ReactiveWebServerApplicationContext.java:139)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.java:72)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:49)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233)
	at com.example.demo.DemoApplication.main(DemoApplication.java:10)
	... 6 more
Caused by: reactor.core.Exceptions$ReactiveException: java.util.concurrent.TimeoutException: HttpServer couldn't be started within 3000ms
	at reactor.core.Exceptions.propagate(Exceptions.java:240)
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:87)
	at reactor.core.publisher.Mono.block(Mono.java:1296)
	at reactor.ipc.netty.tcp.BlockingNettyContext.<init>(BlockingNettyContext.java:55)
	at reactor.ipc.netty.tcp.BlockingNettyContext.<init>(BlockingNettyContext.java:45)
	at reactor.ipc.netty.NettyConnector.start(NettyConnector.java:53)
	at org.springframework.boot.web.embedded.netty.NettyWebServer.start(NettyWebServer.java:59)
	... 16 more
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:88)
		... 21 more
Caused by: java.util.concurrent.TimeoutException: HttpServer couldn't be started within 3000ms
	at reactor.ipc.netty.tcp.BlockingNettyContext.<init>(BlockingNettyContext.java:53)
	... 19 more

Environment

This happens on (at least) macOS Sierra:

➜  demo mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: /usr/local/Cellar/maven/3.5.0/libexec
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.5", arch: "x86_64", family: "mac"

How to replicate

Simply go to http://start.spring.io, create an application with Reactive Web using Spring Boot 2.0.0.BUILD-SNAPSHOT. Try to start it and the above exception appears.

@danielfernandez
Copy link
Contributor Author

Note: This does not happen with Spring Boot 2.0.0.M2.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 13, 2017
@mbhave
Copy link
Contributor

mbhave commented Jul 13, 2017

@danielfernandez I'm not able to reproduce this and my environment looks pretty much the same as yours. I can see that the server starts up fine: Netty started on port(s): 8080.

@bclozel do you think this might be related to the change that went in as part of #9698?

@danielfernandez
Copy link
Contributor Author

Maybe this is normal, given the timeout of 3 seconds. In my laptop, starting Netty with Spring Boot 2.0.0.M2 takes 5 seconds:

2017-07-13 08:31:26.184  INFO 908 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-13 08:31:31.287  INFO 908 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080

This is a 2015 MacBook Pro with an i5 2.9Ghz and 16GB RAM so, maybe that 3000ms timeout is a bit tight?

@wilkinsona
Copy link
Member

Netty should start way faster than that on that machine. @danielfernandez I wonder if you're affected by this: https://thoeni.io/post/macos-sierra-java/

@danielfernandez
Copy link
Contributor Author

@wilkinsona exactly, thank you very much. That was it.

2017-07-13 08:58:01.736  INFO 1237 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-13 08:58:01.866  INFO 1237 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext     : Started HttpServer on /0:0:0:0:0:0:0:0:8080
2017-07-13 08:58:01.870  INFO 1237 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080

Sorry for the alarm, then. At least this ticket will serve as documentation for others having this in the future :). You can close this at your convenience.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 13, 2017
@qintianjie
Copy link

qintianjie commented Nov 10, 2017

I can reproduce this issue when in debug model.

I think it is useful to add timeout parameter from:
org.springframework.boot.web.embedded.netty.NettyWebServer.start()
to
org.springframework.boot.web.embedded.netty.NettyWebServer.start(timeout)

so than we can set the value when init BlockingNettyContext, because the default value is 45S and we can't change it till now.

@Override
public void start(**timeout**) throws WebServerException {
	if (this.nettyContext == null) {
		try {
			this.nettyContext = this.reactorServer.start(this.handlerAdapter);
			// change to 
			// this.nettyContext = this.reactorServer.start(this.handlerAdapter, timeout);
		}

@wilkinsona
Copy link
Member

@qintianjie That's an interesting suggestion. Could you please open a separate issue so that we can make sure that it's considered?

@qintianjie
Copy link

@wilkinsona off course. I will do it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants