[NETCONF-533] channelActive may happen later than handleMessage when connect devices. This will result a java.lang.IllegalStateException and failed the connection. Created: 29/Mar/18  Updated: 06/Aug/18  Resolved: 06/Aug/18

Status: Resolved
Project: netconf
Component/s: netconf
Affects Version/s: None
Fix Version/s: Fluorine

Type: Bug Priority: Medium
Reporter: Wei Jiang Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

connect enough device, or use test case



 Description   

This was not a inevitable phenomenon, it occured when i tried to connect 500 devices.

I believe that  when there are many devices to connect, channelActive may happen later than handleMessage because device will not wait for your hello message. When you handle the message, you need to get session for hello message ,then change state to ESTABLISHED , but the state is IDLE now (Only channelActive can invoke startNegotiation method and change state to OPEN_WAIT.), change will result a IllegalStateException.

  And this happens again and again even if reconnect strategy invoke reconnect. At last, the device will not connect success.

Test case show the stack.(https://git.opendaylight.org/gerrit/#/c/69738/4/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java)

java.lang.IllegalStateException: Cannot change state from IDLE to ESTABLISHED for chanel

    at com.google.common.base.Preconditions.checkState(Preconditions.java:836)
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.changeState(AbstractNetconfSessionNegotiator.java:236)
    at org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator.getSessionForHelloMessage(AbstractNetconfSessionNegotiator.java:173)
    at org.opendaylight.netconf.client.NetconfClientSessionNegotiator.handleMessage(NetconfClientSessionNegotiator.java:68)
    at org.opendaylight.netconf.client.NetconfClientSessionNegotiatorTest.testNegotiatorWhenChannelActiveHappenAfterHandleMessage(NetconfClientSessionNegotiatorTest.java:180)
    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:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)



 Comments   
Comment by Wei Jiang [ 29/Mar/18 ]

i have give a soution on https://git.opendaylight.org/gerrit/#/c/69738/

when you get a message from device, you can check whether channelActive invoke already to ensure the state have been changed to OPEN_WAIT and it is legal to change state to ENSTABLISHED

Comment by Jakub Morvay [ 06/Aug/18 ]

fix:
https://git.opendaylight.org/gerrit/#/c/72446/

Generated at Wed Feb 07 20:15:16 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.