A partial archive of meta.discourse.org as of Tuesday July 18, 2017.

Empty response on discourse login API call

hnaseri

I have about 6k login api calls per day. However about 5% of them do not have any response from discourse. The interesting thing is that there is no sign of these 5% failed api calls in the production.log file too.

Our login api is this:

public static function Login($user_name, $user_pwd){
        $data = array(  'login'=>$user_name,
                        'password'=>$user_pwd,
                        'show_email'=>true,
                        'api_key'=>self::$api_key,
                        'api_username'=>self::$api_user,);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, self::$discourse_url."session");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        $ip = $_SERVER['REMOTE_ADDR'];
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-FORWARDED-FOR: $ip"));
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;
    }

What could be wrong? and where should I look for more information about this matter?

mpalmer

If they’re not making it to production.log, then they’re not getting to Discourse. Trace the request’s progress through whatever chain of proxies you have upstream to determine where they’re getting lost. There you will find the answers you seek.