Unable to start appium server as ServiceUrl appends /wd/hub/

Using C# .Net to programmatically build and start appium

AppiumLocalService got this

public Uri ServiceUrl => new Uri($“http://{IP.ToString()}:{Convert.ToString(Port)}/wd/hub”);
which makes ServiceUrl - “http://127.0.0.1:4723/wd/hub
Then it times out as the serviceUrl is incorrect

But my Appium server got only
[Appium] http://127.0.0.1:4723/ (only accessible from the same host)

There’s not really enough information here to know what’s wrong. But it sounds like you are using Appium V1.x I’d suggest moving to version 2 as 1 is no longer supported as far as I know. Appium 2 doesn’t require the wd/hub.


Sorry , using Appium 2

C# code to construct builder
var builder = new AppiumServiceBuilder();

                _localService=builder.WithIPAddress("127.0.0.1")
                    .UsingPort(4723)
                    .WithAppiumJS(new FileInfo("C:\\Users\\*****\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))
                    .UsingDriverExecutable(new FileInfo("C:\\Program Files\\nodejs\\node.exe"))

                    .WithLogFile(new FileInfo(Path.GetTempPath() + "Log.txt")).Build();

serviceurl returns “http://127.0.0.1:4723/wd/hub”


ServiceUrl automatically appends /wd/hub, if this can be removed , then I may be able to start the server

But this is read only in AppiumLocalService class

I son’t use AppiumServiceBuilder myself but I did some quick research.

I think you need to set the base path argument. Seems like it’s defaulting to /wd/hub Try something like this:

var b = new AppiumServiceBuilder();
OptionCollector argCollector = new OptionCollector().AddArguments(new KeyValuePair<string, string>("--base-path", "/"));
 var localService = b.WithIPAddress("127.0.0.1").WithArguments(argCollector);

I don’t have time to try it out myself so you may need to modify a little.

Your appium client nuget is too old.
Either get the 5.x version or use the --base-path argument for the local service

Sorry , I can see the latest stable as 4.5.

Are you referring to something else?

I tried adding arguments , with --basepath
image

and with callbackaddress. no luck .

.AddArguments(GeneralOptionList.CallbackAddress(“http://127.0.0.1:4723/”))

it still appends “/wd/hub/”

I can see ServiceUrl in the AppiumLocalService class ,


[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] No route found for /wd/hub/status
[HTTP] <-- GET /wd/hub/status 404 7 ms - 211

To update Appium.Webdriver package to 5.x you need to include pre-release packages.

In the code you provide I can’t see anywhere you are setting --base-path argument. I believe you need something like

AddArguments(new KeyValuePair<string, string>("--base-path", "/"))

1 Like

yep , I added the value

.AddArguments(new KeyValuePair<string, string>("–base-path", “/”))
image
But still the ServiceUrl appended with “/wd/hub” .

localservice args value ->
“C:\Users*\AppData\Roaming\npm\node_modules\appium\build\lib\main.js" --port “4723” --address “127.0.0.1” --log "C:\Users*\AppData\Local\Temp\Log.txt” –base-path /

Thank you . The issue got fixed by adding -pa instead of basepath

AddArguments(new KeyValuePair<string, string>("-pa", “/wd/hub”));

2 Likes

Thanks @santhi ! It helped as well in my case