Element not found error

Appium: 1.22.0
Selenium Hub with relay node: 4.1.2
Platform: Android
java_client: 8.0.0
Selenium: 4

This line of code is working fine when I am directly using Appium without Selenium Hub.

AppiumBy.androidUIAutomator(“new UiSelector().resourceId(“username”)”)

But with Selenium Hub, getting error element not found.

ERROR|Element was not found|AppiumBy.androidUIAutomator: new UiSelector().resourceId(“username”)|org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.

compared the both request in Appium logs and found one difference.

Without Hub (Direct Appium request)

[WD Proxy] Proxying [POST /element] to [POST] with body: {“strategy”:"-android uiautomator",“selector”:“new UiSelector().resourceId(“username”)”,“context”:"",“multiple”:false}

Through Hub:

[WD Proxy] Proxying [POST /element] to [POST] with body: {“strategy”:"-android uiautomator",“selector”:“new UiSelector().resourceId(” android:id /username")",“context”:"",“multiple”:false}

We can see that the difference in resourceId parameter. Somehow Appium is getting “username” but with some appended “android:id” string.

Really appreciate any feedback regarding this error. Thanks