changing BaseURL in src/App/Utilities/ApiHttpClient.cs leads to network error #725

Closed
opened 2025-11-26 22:27:10 -06:00 by GiteaMirror · 17 comments
Owner

Originally created by @pdarcos on GitHub (Mar 11, 2019).

As described in the title, I just compiled the app for Android and followed the instructions in the wiki to change the BaseUrl to my self-hosted bitwarden_rs installation.

Specifically I changed 6d11921f45/src/App/Utilities/ApiHttpClient.cs (L40)

to BaseAddress = new Uri("https://my.selfhosted.com"); // Production

and

in 6d11921f45/src/App/Utilities/IdentityHttpClient.cs (L40)

to BaseAddress = new Uri("https://my.selfhosted.com"); // Production

After compiling and running it on my android tablet (8.1) I always get the error message "An error has occurred: There is a problem connecting to the server"

I tried in the app going into Settings and changing the Server URL there under self-hosted environment to https://my.selfhosted.com and it works fine as expected.

Am I doing something wrong? How can I set the BaseURL without having to open the app, go to settings and type it in there?

Thanks

Originally created by @pdarcos on GitHub (Mar 11, 2019). As described in the title, I just compiled the app for Android and followed the instructions in the wiki to change the BaseUrl to my self-hosted bitwarden_rs installation. Specifically I changed https://github.com/bitwarden/mobile/blob/6d11921f45ca210b31387e49f41d30c05fe4978c/src/App/Utilities/ApiHttpClient.cs#L40 to BaseAddress = new Uri("https://my.selfhosted.com"); // Production and in https://github.com/bitwarden/mobile/blob/6d11921f45ca210b31387e49f41d30c05fe4978c/src/App/Utilities/IdentityHttpClient.cs#L40 to BaseAddress = new Uri("https://my.selfhosted.com"); // Production After compiling and running it on my android tablet (8.1) I always get the error message "An error has occurred: There is a problem connecting to the server" I tried in the app going into Settings and changing the Server URL there under self-hosted environment to https://my.selfhosted.com and it works fine as expected. Am I doing something wrong? How can I set the BaseURL without having to open the app, go to settings and type it in there? Thanks
Author
Owner

@pdarcos commented on GitHub (Mar 11, 2019):

Any clues? Debug logs don't show the nature of the error. I know it's not an issue with my let's encrypt certificates since I'm passing the fullchain.pem and can login to the web vault from the tablet using firefox browser. Also, checking with https://www.digicert.com/help/ shows my certs are all fine.

So if it isn't a certificate issue (as I read in many closed posts) I must be doing something wrong when trying to set the BaseAddress as described above.

Is there another way to permanently set the self-hosted URL as BaseAddress in the code?

Thanks

@pdarcos commented on GitHub (Mar 11, 2019): Any clues? Debug logs don't show the nature of the error. I know it's not an issue with my let's encrypt certificates since I'm passing the fullchain.pem and can login to the web vault from the tablet using firefox browser. Also, checking with https://www.digicert.com/help/ shows my certs are all fine. So if it isn't a certificate issue (as I read in many closed posts) I must be doing something wrong when trying to set the BaseAddress as described above. Is there another way to permanently set the self-hosted URL as BaseAddress in the code? Thanks
Author
Owner

@kspearrin commented on GitHub (Mar 11, 2019):

Without knowing what your server's URL is, I'm not sure. Can't you just change from login settings page? Why are you needing to compile locally?

@kspearrin commented on GitHub (Mar 11, 2019): Without knowing what your server's URL is, I'm not sure. Can't you just change from login settings page? Why are you needing to compile locally?
Author
Owner

@pdarcos commented on GitHub (Mar 11, 2019):

Thanks for the reply @kspearrin

I'll email you the URL since I don't want to expose it in a public place.

The reason I want to compile locally is to be able to have the app go directly to my self-hosted server without having to fill out anything. I was able to do this in the past without much issue but this time I'm getting that unhelpful error message. Not sure what changed since I last compiled a working version last summer.

I'll email you the URL now using your website form

@pdarcos commented on GitHub (Mar 11, 2019): Thanks for the reply @kspearrin I'll email you the URL since I don't want to expose it in a public place. The reason I want to compile locally is to be able to have the app go directly to my self-hosted server without having to fill out anything. I was able to do this in the past without much issue but this time I'm getting that unhelpful error message. Not sure what changed since I last compiled a working version last summer. I'll email you the URL now using your website form
Author
Owner

@pdarcos commented on GitHub (Mar 11, 2019):

Just emailed you the URL

@pdarcos commented on GitHub (Mar 11, 2019): Just emailed you the URL
Author
Owner

@kspearrin commented on GitHub (Mar 11, 2019):

I am not sure how the bitwarden_rs server works, but normally you just need to configure the API and identity server URLs. Try debugging the mobile app to see why it is failing.

@kspearrin commented on GitHub (Mar 11, 2019): I am not sure how the bitwarden_rs server works, but normally you just need to configure the API and identity server URLs. Try debugging the mobile app to see why it is failing.
Author
Owner

@pdarcos commented on GitHub (Mar 12, 2019):

The bitwarden_rs server works fine with the app if I set the Server URL in the login settings page, so I don't think there's any compatibility problem. What I don't understand is why I get the connection error message if I set the BaseAddress URL to my server URL.

Unfortunately the debug logs don't really show anything.

[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_long_method_a'.
[Mono] Probing 'java_interop_jnienv_call_long_method_a'.
[Mono] Found as 'java_interop_jnienv_call_long_method_a'.
[Mono] Assembly Ref addref Xamarin.Forms.Platform.Android[0x6a3d16a0] -> Xamarin.Android.Support.Compat[0x6a3d0fe0]: 5
[Mono] Assembly Ref addref Xamarin.Android.Support.Compat[0x6a3d0fe0] -> Java.Interop[0x6a3d1c40]: 9
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.TableViewRenderer
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md50a3fb0d815bba0cfe9c20906cbbc65da.ExtendedTableViewRenderer
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.BaseCellView
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.TextCellRenderer_TextCellView
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_float_field'.
[Mono] Probing 'java_interop_jnienv_set_float_field'.
[Mono] Found as 'java_interop_jnienv_set_float_field'.
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.CellRenderer_RendererHolder
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md50a3fb0d815bba0cfe9c20906cbbc65da.ExtendedEntryRenderer
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_call_static_long_method_a'.
[Mono] Probing 'java_interop_jnienv_call_static_long_method_a'.
[Mono] Found as 'java_interop_jnienv_call_static_long_method_a'.
[Choreographer] Skipped 38 frames! The application may be doing too much work on its main thread.
[View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{e5fd2a6 V.E...... ......ID 0,0-720,1120} during layout: running second layout pass
[View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{ff1e707 V.E...... ........ 0,0-720,1232 #9} during second layout pass: posting in next frame
Thread finished: #3
Thread started: #9
Thread finished: #7
[Mono] Assembly Ref addref Mono.Android[0x6a3d1be0] -> System.Net.Http[0x573ad480]: 4
[Mono] Assembly Ref addref BitwardenAndroid[0x6a3cff60] -> System.Net.Http[0x573ad480]: 5
[Mono] Assembly Ref addref Mono.Android[0x6a3d1be0] -> System[0x56c77840]: 18
[Mono] Assembly Ref addref PCLCrypto[0x6a3d0500] -> Validation[0x6a3d0da0]: 2
[Mono] Unloading image System.Globalization.dll [0x5a90ab00].
[Mono] Image addref System.Globalization[0x573ae380] -> System.Globalization.dll[0x57193100]: 5
[Mono] Config attempting to parse: 'System.Globalization.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Globalization/System.Globalization.config'.
[Mono] Assembly Ref addref Validation[0x6a3d0da0] -> System.Globalization[0x56c79fa0]: 3
[Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Runtime.Serialization[0x56c78ec0]: 4
[Mono] Image addref System.Numerics[0x5a1bc880] -> System.Numerics.dll[0x5a90ab00]: 2
[Mono] Prepared to set up assembly 'System.Numerics' (System.Numerics.dll)
[Mono] Assembly System.Numerics[0x5a1bc880] added to domain RootDomain, ref_count=1
[Mono] AOT: image 'System.Numerics.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Numerics.dll.so" not found
[Mono] AOT: image '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.Numerics.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Numerics.dll.so" not found
[Mono] Config attempting to parse: 'System.Numerics.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Numerics/System.Numerics.config'.
[Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Numerics[0x5a1bc880]: 2
[Mono] Assembly Ref addref System.Numerics[0x5a1bc880] -> mscorlib[0x6a3cfea0]: 73
Loaded assembly: System.Numerics.dll [External]
[Mono] Image addref System.Data[0x5a57fa00] -> System.Data.dll[0x579d5500]: 2
[Mono] Prepared to set up assembly 'System.Data' (System.Data.dll)
[Mono] Assembly System.Data[0x5a57fa00] added to domain RootDomain, ref_count=1
[Mono] AOT: image 'System.Data.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Data.dll.so" not found
[Mono] AOT: image '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.Data.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Data.dll.so" not found
[Mono] Config attempting to parse: 'System.Data.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Data/System.Data.config'.
[Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Data[0x5a57fa00]: 2
[Mono] Assembly Ref addref System.Data[0x5a57fa00] -> mscorlib[0x6a3cfea0]: 74
[Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System.Xml[0x59d96b40]: 6
Loaded assembly: System.Data.dll [External]
[Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System[0x56c77840]: 19
[Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System.Core[0x6a3d1dc0]: 9
[System] ClassLoader referenced unknown path: /system/framework/tcmclient.jar
[Choreographer] Skipped 90 frames! The application may be doing too much work on its main thread.
Thread started: #10
Thread started: #11
Thread started: #12
[Mono] Assembly Ref addref BitwardenAndroid[0x6a3cff60] -> BouncyCastle.Crypto[0x6a3cffc0]: 2
Thread finished: #12

and after trying to login again:

A OnStart
[Mono] DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
[Mono] Searching for 'sqlite3_column_int'.
OnStart
A OnResume
[View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{82e9b16 V.E...... ......ID 0,0-720,1232} during layout: running second layout pass
[View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{7299589 V.E...... ........ 0,0-720,1232 #1f} during second layout pass: posting in next frame
[View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{8fbd588 V.E...... ......ID 0,0-720,1120} during layout: running second layout pass
[View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{a6fb77d V.E...... ........ 0,0-720,1232 #27} during second layout pass: posting in next frame
Thread finished: #13
Thread started: #17
Thread finished: #15
Thread finished: #14
Thread started: #18
Thread started: #19
Thread started: #20
Thread finished: #18

I was hoping the debug logs would show some useful info. Checking server side I see that the attempted login never even reaches the server, so I would suspect some problem on the client.

Any clues?

Thanks

@pdarcos commented on GitHub (Mar 12, 2019): The bitwarden_rs server works fine with the app if I set the Server URL in the login settings page, so I don't think there's any compatibility problem. What I don't understand is why I get the connection error message if I set the BaseAddress URL to my server URL. Unfortunately the debug logs don't really show anything. [Mono] DllImport searching in: '__Internal' ('(null)'). [Mono] Searching for 'java_interop_jnienv_call_long_method_a'. [Mono] Probing 'java_interop_jnienv_call_long_method_a'. [Mono] Found as 'java_interop_jnienv_call_long_method_a'. [Mono] Assembly Ref addref Xamarin.Forms.Platform.Android[0x6a3d16a0] -> Xamarin.Android.Support.Compat[0x6a3d0fe0]: 5 [Mono] Assembly Ref addref Xamarin.Android.Support.Compat[0x6a3d0fe0] -> Java.Interop[0x6a3d1c40]: 9 [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.TableViewRenderer [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md50a3fb0d815bba0cfe9c20906cbbc65da.ExtendedTableViewRenderer [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.BaseCellView [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.TextCellRenderer_TextCellView [Mono] DllImport searching in: '__Internal' ('(null)'). [Mono] Searching for 'java_interop_jnienv_set_float_field'. [Mono] Probing 'java_interop_jnienv_set_float_field'. [Mono] Found as 'java_interop_jnienv_set_float_field'. [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.CellRenderer_RendererHolder [art] JNI RegisterNativeMethods: attempt to register 0 native methods for md50a3fb0d815bba0cfe9c20906cbbc65da.ExtendedEntryRenderer [Mono] DllImport searching in: '__Internal' ('(null)'). [Mono] Searching for 'java_interop_jnienv_call_static_long_method_a'. [Mono] Probing 'java_interop_jnienv_call_static_long_method_a'. [Mono] Found as 'java_interop_jnienv_call_static_long_method_a'. [Choreographer] Skipped 38 frames! The application may be doing too much work on its main thread. [View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{e5fd2a6 V.E...... ......ID 0,0-720,1120} during layout: running second layout pass [View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{ff1e707 V.E...... ........ 0,0-720,1232 #9} during second layout pass: posting in next frame Thread finished: <Thread Pool> #3 Thread started: <Thread Pool> #9 Thread finished: <Thread Pool> #7 [Mono] Assembly Ref addref Mono.Android[0x6a3d1be0] -> System.Net.Http[0x573ad480]: 4 [Mono] Assembly Ref addref BitwardenAndroid[0x6a3cff60] -> System.Net.Http[0x573ad480]: 5 [Mono] Assembly Ref addref Mono.Android[0x6a3d1be0] -> System[0x56c77840]: 18 [Mono] Assembly Ref addref PCLCrypto[0x6a3d0500] -> Validation[0x6a3d0da0]: 2 [Mono] Unloading image System.Globalization.dll [0x5a90ab00]. [Mono] Image addref System.Globalization[0x573ae380] -> System.Globalization.dll[0x57193100]: 5 [Mono] Config attempting to parse: 'System.Globalization.dll.config'. [Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Globalization/System.Globalization.config'. [Mono] Assembly Ref addref Validation[0x6a3d0da0] -> System.Globalization[0x56c79fa0]: 3 [Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Runtime.Serialization[0x56c78ec0]: 4 [Mono] Image addref System.Numerics[0x5a1bc880] -> System.Numerics.dll[0x5a90ab00]: 2 [Mono] Prepared to set up assembly 'System.Numerics' (System.Numerics.dll) [Mono] Assembly System.Numerics[0x5a1bc880] added to domain RootDomain, ref_count=1 [Mono] AOT: image 'System.Numerics.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Numerics.dll.so" not found [Mono] AOT: image '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.Numerics.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Numerics.dll.so" not found [Mono] Config attempting to parse: 'System.Numerics.dll.config'. [Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Numerics/System.Numerics.config'. [Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Numerics[0x5a1bc880]: 2 [Mono] Assembly Ref addref System.Numerics[0x5a1bc880] -> mscorlib[0x6a3cfea0]: 73 Loaded assembly: System.Numerics.dll [External] [Mono] Image addref System.Data[0x5a57fa00] -> System.Data.dll[0x579d5500]: 2 [Mono] Prepared to set up assembly 'System.Data' (System.Data.dll) [Mono] Assembly System.Data[0x5a57fa00] added to domain RootDomain, ref_count=1 [Mono] AOT: image 'System.Data.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Data.dll.so" not found [Mono] AOT: image '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.Data.dll.so' not found: dlopen failed: library "/data/app/com.x8bit.bitwarden-1/lib/arm/libaot-System.Data.dll.so" not found [Mono] Config attempting to parse: 'System.Data.dll.config'. [Mono] Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Data/System.Data.config'. [Mono] Assembly Ref addref netstandard[0x56c77720] -> System.Data[0x5a57fa00]: 2 [Mono] Assembly Ref addref System.Data[0x5a57fa00] -> mscorlib[0x6a3cfea0]: 74 [Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System.Xml[0x59d96b40]: 6 Loaded assembly: System.Data.dll [External] [Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System[0x56c77840]: 19 [Mono] Assembly Ref addref System.Data[0x5a57fa00] -> System.Core[0x6a3d1dc0]: 9 [System] ClassLoader referenced unknown path: /system/framework/tcmclient.jar [Choreographer] Skipped 90 frames! The application may be doing too much work on its main thread. Thread started: <Thread Pool> #10 Thread started: <Thread Pool> #11 Thread started: <Thread Pool> #12 [Mono] Assembly Ref addref BitwardenAndroid[0x6a3cff60] -> BouncyCastle.Crypto[0x6a3cffc0]: 2 Thread finished: <Thread Pool> #12 and after trying to login again: A OnStart [Mono] DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so'). [Mono] Searching for 'sqlite3_column_int'. OnStart A OnResume [View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{82e9b16 V.E...... ......ID 0,0-720,1232} during layout: running second layout pass [View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{7299589 V.E...... ........ 0,0-720,1232 #1f} during second layout pass: posting in next frame [View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{8fbd588 V.E...... ......ID 0,0-720,1120} during layout: running second layout pass [View] requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{a6fb77d V.E...... ........ 0,0-720,1232 #27} during second layout pass: posting in next frame Thread finished: <Thread Pool> #13 Thread started: <Thread Pool> #17 Thread finished: <Thread Pool> #15 Thread finished: <Thread Pool> #14 Thread started: <Thread Pool> #18 Thread started: <Thread Pool> #19 Thread started: <Thread Pool> #20 Thread finished: <Thread Pool> #18 I was hoping the debug logs would show some useful info. Checking server side I see that the attempted login never even reaches the server, so I would suspect some problem on the client. Any clues? Thanks
Author
Owner
@kspearrin commented on GitHub (Mar 13, 2019): Try setting breakpoints. For example, here: https://github.com/bitwarden/mobile/blob/master/src/App/Repositories/ConnectApiRepository.cs#L52 or here https://github.com/bitwarden/mobile/blob/master/src/App/Repositories/ConnectApiRepository.cs#L73
Author
Owner

@pdarcos commented on GitHub (Mar 14, 2019):

Thanks Kyle.

I've done as you said and here's the results from both breakpoints
L52 is here https://paste.ee/d/Evc19/0
and L73 is here https://paste.ee/d/I3UGF

Any clues?

@pdarcos commented on GitHub (Mar 14, 2019): Thanks Kyle. I've done as you said and here's the results from both breakpoints L52 is here https://paste.ee/d/Evc19/0 and L73 is here https://paste.ee/d/I3UGF Any clues?
Author
Owner

@kspearrin commented on GitHub (Mar 14, 2019):

What is the exception being caught on 73? Might need to change it to catch (Exception e) so that you can inspect the exception

@kspearrin commented on GitHub (Mar 14, 2019): What is the exception being caught on 73? Might need to change it to `catch (Exception e)` so that you can inspect the exception
Author
Owner

@pdarcos commented on GitHub (Mar 14, 2019):

Thanks for your help @kspearrin

I caught some exceptions relating to Newtonsoft.Json which could be the cause of the problem. It seems this nougat package is having problems parsing the URL I inserted for my self-hosted server, which then leads it to fail later when trying to connect.

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in :0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in :0
at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in :0
at Bit.App.Repositories.BaseApiRepository+d__24.MoveNext () [0x00102] in /mobile/src/App/Repositories/BaseApiRepository.cs:157

and also

Bit.App.Repositories.BaseApiRepository.d__22<Bit.App.Models.Api.HandleErrorAsync() in /mobile/src/App/Repositories/BaseApiRepository.cs:122

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in :0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in :0
at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in :0
at Bit.App.Repositories.BaseApiRepository+d__24.MoveNext () [0x00102] in /mobile/src/App/Repositories/BaseApiRepository.cs:157
at Bit.App.Repositories.BaseApiRepository+d__22`1[T].MoveNext () [0x00038] in /mobile/src/App/Repositories/BaseApiRepository.cs:122

and

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in :0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in :0
at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in :0
at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in :0
at Bit.App.Repositories.ConnectApiRepository+d__3.MoveNext () [0x0023a] in /mobile/src/App/Repositories/ConnectApiRepository.cs:52

Bit.App.Repositories.ConnectApiRepository.PostTokenAsync() in /mobile/src/App/Repositories/ConnectApiRepository.cs:52

Any idea how to solve this?

Thanks

@pdarcos commented on GitHub (Mar 14, 2019): Thanks for your help @kspearrin I caught some exceptions relating to Newtonsoft.Json which could be the cause of the problem. It seems this nougat package is having problems parsing the URL I inserted for my self-hosted server, which then leads it to fail later when trying to connect. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12. at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0 at Bit.App.Repositories.BaseApiRepository+<ParseErrorsAsync>d__24.MoveNext () [0x00102] in /mobile/src/App/Repositories/BaseApiRepository.cs:157 and also Bit.App.Repositories.BaseApiRepository.<HandleErrorAsync>d__22<Bit.App.Models.Api.HandleErrorAsync() in /mobile/src/App/Repositories/BaseApiRepository.cs:122 Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12. at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0 at Bit.App.Repositories.BaseApiRepository+<ParseErrorsAsync>d__24.MoveNext () [0x00102] in /mobile/src/App/Repositories/BaseApiRepository.cs:157 at Bit.App.Repositories.BaseApiRepository+<HandleErrorAsync>d__22`1[T].MoveNext () [0x00038] in /mobile/src/App/Repositories/BaseApiRepository.cs:122 and Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 12. at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00013] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x0000c] in <d32db49e5e3440729da31845c03ddc3a>:0 at Newtonsoft.Json.Linq.JObject.Parse (System.String json) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0 at Bit.App.Repositories.ConnectApiRepository+<PostTokenAsync>d__3.MoveNext () [0x0023a] in /mobile/src/App/Repositories/ConnectApiRepository.cs:52 Bit.App.Repositories.ConnectApiRepository.PostTokenAsync() in /mobile/src/App/Repositories/ConnectApiRepository.cs:52 Any idea how to solve this? Thanks
Author
Owner

@kspearrin commented on GitHub (Mar 14, 2019):

Why is it having problems parsing your URL? What's non-standard about it?

@kspearrin commented on GitHub (Mar 14, 2019): Why is it having problems parsing your URL? What's non-standard about it?
Author
Owner

@pdarcos commented on GitHub (Mar 14, 2019):

That’s what I’d like to know too.
Nothing special about the URL. It’s a standard one with .io TLD

And the fact it works fine when I change it manually in the login settings section is even more baffling.

Sent from my mobile device

On 14 Mar 2019, at 20:13, Kyle Spearrin notifications@github.com wrote:

Why is it having problems parsing your URL? What's non-standard about it?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@pdarcos commented on GitHub (Mar 14, 2019): That’s what I’d like to know too. Nothing special about the URL. It’s a standard one with .io TLD And the fact it works fine when I change it manually in the login settings section is even more baffling. Sent from my mobile device > On 14 Mar 2019, at 20:13, Kyle Spearrin <notifications@github.com> wrote: > > Why is it having problems parsing your URL? What's non-standard about it? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub, or mute the thread.
Author
Owner

@pdarcos commented on GitHub (Mar 15, 2019):

This seems like it maybe related

https://github.com/ngx-translate/core/issues/649

@pdarcos commented on GitHub (Mar 15, 2019): This seems like it maybe related https://github.com/ngx-translate/core/issues/649
Author
Owner

@pdarcos commented on GitHub (Mar 15, 2019):

Hi @kspearrin

Finally was able to dig deeper and found out the problem.
The problem is that somewhere your code is adding an extra / at the end of the BaseAddress so it then has a double // in the address which obviously fails (see below)

{Method: POST, RequestUri: 'https://my.domain.com//connect/token', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers: { Device-Type: 0 Accept: application/json Content-Type: application/x-www-form-urlencoded Content-Length: 274 }}

Now I'm 100% positive that in BaseAddress I've set the URL without the trailing / so somewhere it is being added by mistake.

Any idea where this is happening?

Cheers

@pdarcos commented on GitHub (Mar 15, 2019): Hi @kspearrin Finally was able to dig deeper and found out the problem. The problem is that somewhere your code is adding an extra / at the end of the BaseAddress so it then has a double // in the address which obviously fails (see below) {Method: POST, RequestUri: 'https://my.domain.com//connect/token', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers: { Device-Type: 0 Accept: application/json Content-Type: application/x-www-form-urlencoded Content-Length: 274 }} Now I'm 100% positive that in BaseAddress I've set the URL without the trailing / so somewhere it is being added by mistake. Any idea where this is happening? Cheers
Author
Owner

@kspearrin commented on GitHub (Mar 16, 2019):

probably in the repositories themselves. that connect call happens in the ConnectApiRepository that I linked above.

@kspearrin commented on GitHub (Mar 16, 2019): probably in the repositories themselves. that connect call happens in the ConnectApiRepository that I linked above.
Author
Owner

@pdarcos commented on GitHub (Mar 18, 2019):

That's what I thought originally but no matter what I end up putting in here it always gives me the POST with the BaseURL and the double forward slash which always leads to the connection error.
RequestUri = new Uri(string.Concat(client.BaseAddress, "/connect/token")),

It seems almost as if VS is ignoring my changes even though I clean and build from scratch with different strings in RequestUri but none of them seem to be used.

Very confused as to why hardcoding something like this doesn't work:

RequestUri = new Uri("https://my.domain.com/connect/token"),

Any ideas?

@pdarcos commented on GitHub (Mar 18, 2019): That's what I thought originally but no matter what I end up putting in [here](https://github.com/bitwarden/mobile/blob/db7f2622c8ce89808b4c88dc31d8da7503078922/src/App/Repositories/BaseApiRepository.cs#L57) it always gives me the POST with the BaseURL and the double forward slash which always leads to the connection error. RequestUri = new Uri(string.Concat(client.BaseAddress, "/connect/token")), It seems almost as if VS is ignoring my changes even though I clean and build from scratch with different strings in RequestUri but none of them seem to be used. Very confused as to why hardcoding something like this doesn't work: RequestUri = new Uri("https://my.domain.com/connect/token"), Any ideas?
Author
Owner

@pdarcos commented on GitHub (Mar 26, 2019):

Just had to adjust the paths and now it works.

@pdarcos commented on GitHub (Mar 26, 2019): Just had to adjust the paths and now it works.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#725