0

My APP now always crash when requesting a post command.

At the moment APP request the mobile phone is not connect to any device via wifi.

It should just cause an exception I thought.

But the APP just crash and closed. Didn't throw any exception.

Crash at here: "var resp = await myHttpClient.PostAsync(DC1_URL.URL, httpContent);"

async Task<response> PostRequest_Wifi_Status()
{
    try
    {
        app_connection_request app_connection_request = new app_connection_request
        {
            url = "app_con_req",
            request = "wifi_status",
        };
        var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(app_connection_request));
        var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
        var myHttpClient = new HttpClient()
        {
            Timeout = TimeSpan.FromSeconds(10)
        };
        //Crash on next line
        var resp = await myHttpClient.PostAsync(DC1_URL.URL, httpContent);
        if (resp.IsSuccessStatusCode)
        {
            var json = await resp.Content.ReadAsStringAsync();
            var result = JsonConvert.DeserializeObject<response(resp.Content.ReadAsStringAsync().Result);
            {
                return result;
            }
        }
        return no_res;  //"-1";
    }
    catch (Exception e)
    {
        return no_res;  //"-1";
    }
}

And in the log. I got the message (22450): mono_w32socket_convert_error: no translation into winsock error for (64) "Machine is not on the network"

Following are more log

04-08 19:09:24.884 D/ViewRootImpl@71d0495[MainActivity](22450): Surface release. android.view.ViewRootImpl.doDie:7931 android.view.ViewRootImpl.die:7899 android.view.WindowManagerGlobal.removeViewLocked:497 android.view.WindowManagerGlobal.removeView:435 android.view.WindowManagerImpl.removeViewImmediate:124 android.app.Dialog.dismissDialog:518 android.app.Dialog.dismiss:501 android.app.Dialog.cancel:1462 
04-08 19:09:24.896 W/InputEventReceiver(22450): Attempted to finish an input event but the input event receiver has already been disposed.
04-08 19:09:24.897 W/ViewRootImpl@71d0495[MainActivity](22450): Dropping event due to root view being removed: 
04-08 19:09:24.897 E/ViewRootImpl@71d0495[MainActivity](22450): mStopped=false mHasWindowFocus=true mPausedForTransition=false
04-08 19:09:24.897 W/InputEventReceiver(22450): Attempted to finish an input event but the input event receiver has already been disposed.
04-08 19:09:24.897 D/InputTransport(22450): Input channel destroyed: fd=96
04-08 19:09:24.900 E/ViewRootImpl(22450): sendUserActionEvent() returned.
04-08 19:09:24.900 D/ViewRootImpl@478d4cc[MainActivity](22450): MSG_WINDOW_FOCUS_CHANGED 1 1
04-08 19:09:24.901 D/InputMethodManager(22450): prepareNavigationBarInfo() DecorView@4094973[MainActivity]
04-08 19:09:24.901 D/InputMethodManager(22450): getNavigationBarColor() -855310
Xamarin.Android returned no custom HttpClientHandler. Defaulting to System.Net.Http.HttpClientHandler
04-08 19:09:29.737 I/mono-stdout(22450): Xamarin.Android returned no custom HttpClientHandler. Defaulting to System.Net.Http.HttpClientHandler
04-08 19:09:29.741 F/        (22450): mono_w32socket_convert_error: no translation into winsock error for (64) "Machine is not on the network"
04-08 19:09:29.742 F/libc    (22450): Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 22783 (Thread Pool Wor), pid 22450 (solar_1_0_1.app)

Before request the cmd.

The APP have executed function :"ForceWifiOverCellular()" metioned at this thread. Question: 56578475

Because I need my cmd being request via wifi. Not mobiledata.

Can Anyone help to solve this crash.

Thank you.

CC.Wang
  • 111
  • 1
  • 12

0 Answers0