Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

connect ECONNREFUSED 127.0.0.1:443 #31

Open
stephenjesus opened this issue Dec 7, 2018 · 1 comment
Open

connect ECONNREFUSED 127.0.0.1:443 #31

stephenjesus opened this issue Dec 7, 2018 · 1 comment

Comments

@stephenjesus
Copy link

when i tried curl command for python is working fine...but i tried to integrate in node js it shows some
connection issue..
{ message: 'connect ECONNREFUSED 127.0.0.1:443',
stack: 'Error: connect ECONNREFUSED 127.0.0.1:443\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)',
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 44
@prasmussen @javierprovecho

@stephenjesus
Copy link
Author

const compileUrl: string = 'https://run.glot.io';

        const post_options: any = {
            // host: compileUrl,
            url : 'https://run.glot.io/languages/python/latest',
            method: 'POST',
            json: true, 
            headers: {
                'Content-Type': 'application/json',
                'Authorization': 'Token f4410576-e492-4dc9-8e9a-b7d5c14f2001',
            },
           body : JSON.stringify({"files": [{"name": "main.py", "content": "print(42)"}]})
        };
        logger.info(post_options , 'post options');
        const post_req = http.request(post_options, (res: any) => {
            res.setEncoding('utf8');
            let compilerdata = '';
            res.on('data', (chunk: any) => {
                compilerdata += chunk;
            });
            res.on('end', () => {
                if (payload) {
                    try {
                        const output = JSON.parse(compilerdata);
                        output.output ? (output.output = JSON.parse(output.output)) : '';
                        output.errors ? (output.errors = JSON.parse(output.errors)) : '';
                        resolve(JSON.stringify(output));
                    } catch (err) {
                        const tempObj = {
                            success: false,
                            message: err
                        };
                        resolve(JSON.stringify(tempObj));
                    }
                } else {
                    const tempObj = {
                        success: false,
                        message: 'No data from compiler'
                    };
                    resolve(JSON.stringify(tempObj));
                }
            });
        }).on('error', (err: any) => {
            logger.info(err);
            const tempObj = {
                success: false,
                message: 'Error Occurred'
            };
            resolve(JSON.stringify(tempObj));
        });
        post_req.write(payload.toString());
        post_req.end();
    });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant