twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
Other
382 stars 356 forks source link

SmppSession#isBound returns true even when the channel closed #93

Open krasa opened 9 years ago

krasa commented 9 years ago

easily reproducible on both master and netty4, connect and then shutdown the server

public static void main(String[] args) throws UnrecoverablePduException, SmppChannelException, InterruptedException, SmppTimeoutException {
        DefaultSmppClient clientBootstrap = new DefaultSmppClient(Executors.newCachedThreadPool());
        SmppSessionConfiguration config = new SmppSessionConfiguration();
        config.setWindowSize(1);
        config.setHost("127.0.0.1");
        config.setPort(5000);
        try {
            SmppSession session = clientBootstrap.bind(config,new DefaultSmppSessionHandler());
            while (session.isBound()) { //always true
                System.out.println("bound");
                Thread.sleep(1000);
            }
        } finally {
            System.out.println("destroying");
            clientBootstrap.destroy();
        }
    }

Seems to me that DefaultSmppSession#fireChannelClosed should update the state

jjlauer commented 9 years ago

Looks like a good find. Do you think you could produce a unit test & fix in a PR?

krasa commented 9 years ago

yeah, sure.