Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChannelHandler is not a sharable Handler

Tags:

java

netty

Alright so I am experimenting with Netty 4.0.19 (which is great by the way) and having one connection works fine, but once there are multiple connections there is an error that the handler is not a shared handler and cannot have multiple items.

This is my Handler class: ChannelManager.java

I was thinking, maybe every connection needs its own handler, but then I'm not sure how I will implement that in my current environment. Any suggestions or ideas?

EDIT : I wasn't sure how to ask this question on google... so excuse me if this question already exists.

I think it has something to do with line 59 in the code. I saw some use of a ChannelInitializer but I don't know how to use that.

like image 266
Limnic Avatar asked May 21 '14 16:05

Limnic


1 Answers

if your handler can be shared between multiple clients you need to annotate the class with:

@ChannelHandler.Sharable
like image 72
Derek Troy-West Avatar answered Oct 20 '22 00:10

Derek Troy-West