Session Identified by is unknown

this worked thanks a lot @Umer_Saeed

Thanks @Umer_Saeed.
I did the same and its solve my issue.

Thanks, this helped. I wish there was a permanent solution to this though.

Thank you, it worked

yep done . it works thanks alot

Iā€™ve seen this in the testing Iā€™m doing as well: Appium 2.4.1/ C# webdriver 4.4.5 / UIAutomator2 3.0.4

Everything working perfectly, we press a couple of keys to get to home, verify a bunch of stuff, then when we hit the home key again, we magically seem to send the wrong session id?!
Initial ID is bb71daaf-7726-44c0-af44-9a6aa36ebe7e and works fine
Then suddenly itā€™s aecebb49-34a4-414b-9299-b6f15d788a4f!! And TBH this looks like it came from the PC side - this is the log from the device, and we see the POST with the random GUIDā€¦?

Iā€™ve tried uninstalling the Appium apps, no change - last time this happened, I updated to UIAutomator2 v3.0.4 and it fixed things - maybe Iā€™ll try a newer webdriver / Appium server?

For context -

04-05 14:14:34.323 20396 20428 I appium: PressKeyCode command
04-05 14:14:34.323 20396 20428 I appium: Calling PressKeyCodeā€¦
04-05 14:14:34.384 20396 20428 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œbb71daaf-7726-44c0-af44-9a6aa36ebe7eā€,ā€œvalueā€:null}
04-05 14:14:34.680 20396 20428 I appium: channel read: POST /session/bb71daaf-7726-44c0-af44-9a6aa36ebe7e/appium/device/press_keycode
04-05 14:14:34.687 20396 20428 I appium: PressKeyCode command
04-05 14:14:34.687 20396 20428 I appium: Calling PressKeyCodeā€¦
04-05 14:14:34.734 20396 20428 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œbb71daaf-7726-44c0-af44-9a6aa36ebe7eā€,ā€œvalueā€:null}
04-05 14:14:34.760 20396 20428 I appium: channel read: POST /session/bb71daaf-7726-44c0-af44-9a6aa36ebe7e/element
04-05 14:14:34.762 20396 20428 I appium: FindElement command
04-05 14:14:34.767 20396 20428 I appium: method: ā€˜idā€™, selector: ā€˜com.android.launcher3:id/hotseatā€™
04-05 14:14:34.772 20396 20428 I appium: Waiting up to 10000ms for the device to idle
04-05 14:14:34.849 20396 20428 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œbb71daaf-7726-44c0-af44-9a6aa36ebe7eā€,ā€œvalueā€:{ā€œELEMENTā€:ā€œ00000000-0000-01ad-ffff-ffff00000007ā€,ā€œelement-6066-11e4-a52e-4f735466cecfā€:ā€œ00000000-0000-01ad-ffff-ffff00000007ā€}}
04-05 14:14:34.882 20396 20428 I appium: channel read: POST /session/bb71daaf-7726-44c0-af44-9a6aa36ebe7e/element
04-05 14:14:34.885 20396 20428 I appium: FindElement command
04-05 14:14:34.895 20396 20428 I appium: method: ā€˜idā€™, selector: ā€˜com.android.launcher3:id/workspaceā€™
04-05 14:14:34.897 20396 20428 I appium: Waiting up to 10000ms for the device to idle
04-05 14:14:34.949 20396 20428 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œbb71daaf-7726-44c0-af44-9a6aa36ebe7eā€,ā€œvalueā€:{ā€œELEMENTā€:ā€œ00000000-0000-01ad-ffff-ffff00000006ā€,ā€œelement-6066-11e4-a52e-4f735466cecfā€:ā€œ00000000-0000-01ad-ffff-ffff00000006ā€}}
04-05 14:14:34.967 20396 20428 I appium: channel read: POST /session/bb71daaf-7726-44c0-af44-9a6aa36ebe7e/element
04-05 14:14:34.970 20396 20428 I appium: FindElement command
04-05 14:14:34.976 20396 20428 I appium: method: ā€˜idā€™, selector: ā€˜com.android.launcher3:id/page_indicatorā€™
04-05 14:14:34.978 20396 20428 I appium: Waiting up to 10000ms for the device to idle
04-05 14:14:35.027 20396 20428 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œbb71daaf-7726-44c0-af44-9a6aa36ebe7eā€,ā€œvalueā€:{ā€œELEMENTā€:ā€œ00000000-0000-01ad-ffff-ffff0000000aā€,ā€œelement-6066-11e4-a52e-4f735466cecfā€:ā€œ00000000-0000-01ad-ffff-ffff0000000aā€}}
04-05 14:14:35.118 20396 20424 I appium: channel read: POST /session/aecebb49-34a4-414b-9299-b6f15d788a4f/appium/device/press_keycode
04-05 14:14:35.123 20396 20424 I appium: PressKeyCode command
04-05 14:14:35.137 20396 20424 I appium: AppiumResponse: {ā€œsessionIdā€:ā€œaecebb49-34a4-414b-9299-b6f15d788a4fā€,ā€œvalueā€:{ā€œerrorā€:ā€œinvalid session idā€,ā€œmessageā€:ā€œThe session identified by aecebb49-34a4-414b-9299-b6f15d788a4f is not knownā€,ā€œstacktraceā€:ā€œio.appium.uiautomator2.common.exceptions.NoSuchDriverException: The session identified by aecebb49-34a4-414b-9299-b6f15d788a4f is not known\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:54)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:259)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:253)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:77)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)\n\tat io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)\n\tat java.lang.Thread.run(Thread.java:920)\nā€}}