Skip to content

Socket has been ended by other party #7

@ajay92x

Description

@ajay92x

I have tried using the following code to get the market data and it is working but sometimes I'm getting the error "socket has been ended by other party" and then I have to restart the server to make it work again.

var tls = require('tls');

/* Socket connection options */

var options = {
host: 'stream-api.betfair.com',
// host: 'stream-api-integration.betfair.com',
port: 443
}

/* Establish connection to the socket */

var client = tls.connect(options, function () {
console.log("Connected");
});

/* Send authentication message */

client.write('{"op": "authentication", "appKey": "APIKEY", "session": "TOKEN"}\r\n');

/* Subscribe to order/market stream */
stream.write({"op":"marketSubscription","marketFilter":{"marketIds":["1.160865586"],"bettingTypes":["ODDS"],"eventTypeIds":["2"],"eventIds":["29390842"]},"marketDataFilter":{}}\r\n);

client.on('data', function(data) {
console.log('Received: ' + data);
});

client.on('close', function() {
console.log('Connection closed');
});

client.on('error', function(err) {
console.log('Error:' + err);
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions