mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

How can I use Netty SocketIO in Grails application? #250

Closed ghost closed 9 years ago

ghost commented 9 years ago

When I try to start SocketIOServer in my Grails application the exception appears

Stacktrace: ERROR socketio.SocketIOServer - SocketIO server start failed at port: 11111! ERROR context.GrailsContextLoaderListener - Error initializing the application: Unresolved address java.net.SocketException: Unresolved address at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:484) at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1080) at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:430) at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:415) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:903) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:197) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:350) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) at java.lang.Thread.run(Thread.java:745) Caused by: java.nio.channels.UnresolvedAddressException ... 13 more

I tried to start netty server in different places (Bootstrap.groovy, services), the same error appears

My code: Configuration config = new Configuration(); config.setHostname("http://localhost"); config.setPort(11111); SocketIOServer server = new SocketIOServer(config); server.start()

Have you any ideas how to use it Grails? Thanks.

mrniko commented 9 years ago

try this:

config.setHostname("localhost");
config.setPort(11111);