使用AWS弹性beantalk进行502 Badgateway的改进-Kotlin

时间:2020-08-15 13:16:50

标签: amazon-web-services kotlin amazon-elastic-beanstalk retrofit bad-gateway

界面:

@Headers("Content-Type:application/json")

    @POST("login/")
    open fun signin(
        @Body jsonObject: JSONObject?
    ): Call<ResponseBody?>?

我的登录功能:

private fun signin(comp_number: String, password: String){

        val retIn = RetrofitInstance.getRetrofitInstance().create(ApiInterface::class.java)


        val rootObject= JSONObject()
        rootObject.put( "comp_pnumber",comp_number)
        rootObject.put("password",password)


        Log.e("TAG HEADER",  rootObject.toString());

        val call: Call<ResponseBody?>? = retIn.signin( rootObject)


        if (call != null) {
            call.enqueue(object : Callback<ResponseBody?> {
                override fun onResponse(
                    callback: Call<ResponseBody?>,
                    response: Response<ResponseBody?>
                ) {

                    Log.e("TAG RESPONSE",  response.toString());
                    if (response.code() == 502) {

                        Toast.makeText(this@LoginActivity, "Bad Gateway!", Toast.LENGTH_SHORT).show()

                    }
                    else if (response.code() == 200) {

                        Toast.makeText(this@LoginActivity, "Login success!", Toast.LENGTH_SHORT).show()
                        val intent = Intent(this@LoginActivity, MainActivity::class.java)
                        startActivity(intent)
                    } else {
                        Toast.makeText(this@LoginActivity, "Login failed!", Toast.LENGTH_SHORT).show()
                    }
                }

                override fun onFailure(
                    call: Call<ResponseBody?>,
                    t: Throwable
                ) {
                    Toast.makeText(
                        this@LoginActivity,
                        t.message,
                        Toast.LENGTH_SHORT
                    ).show()
                }
            })
        }

我正在获取响应{protocol = http / 1.1,代码= 502,消息=错误的网关,网址

正在对邮递员进行工作。我已经在elastc bean茎中取消了节点api的作用。

0 个答案:

没有答案