octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
7.03k stars 1.03k forks source link

Socket hangup #46

Closed rsileoni closed 8 years ago

rsileoni commented 12 years ago

The following snippet of code, always thrown an error

        var github = new GitHubApi({
            version: "3.0.0",
            debug: true
        });
        github.authenticate({
            type: "oauth",
            token: token
        });
        github.gitdata.createBlob(
            {
                user: username,
                repo: reponame,
                content: "Content of the blob",
                encoding: "utf-8"
            },
            function(err, res) {
                if (err) {
                    console.log(err);
                }
                console.log(res);
            }
        );

Error: socket hang up at createHangUpError (http.js:1124:15) at CleartextStream.socketCloseListener (http.js:1173:23) at CleartextStream.emit (events.js:88:20) at Array.0 (tls.js:792:22) at EventEmitter._tickCallback (node.js:190:38)

I am using Node 0.6.20. Is it something related to https implementation ? Probably is worth to note that others API call (like repos.getBranches or repos.create) works without any issue.

Thanks

Roberto

pekkast commented 12 years ago

A bit old issue, but it seems that you are using http-protocol as index.js defaults to http.

var protocol = this.config.protocol || this.constants.protocol || "http";

Try adding protocol

var github = new GitHubApi({
    version: "3.0.0",
    protocol: 'https',
    debug: true
});

Github api says that all access is through http, but i wouldn't be suprised if some would work with http.