Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket has been ended by other party #7

Open
ajay92x opened this issue Aug 1, 2019 · 2 comments
Open

Socket has been ended by other party #7

ajay92x opened this issue Aug 1, 2019 · 2 comments

Comments

@ajay92x
Copy link

ajay92x commented Aug 1, 2019

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);
})

@liampauling
Copy link

Yeah this happens, it’s do with the socket connection being closed / dropped.

Not sure on the details of this library but you need to catch the error and resubscribe, nothing else you as a client can do.

@ajay92x
Copy link
Author

ajay92x commented Aug 6, 2019

@liampauling Thanks for your response.
I'm resubscribing right now on connection drop. I thought there must be some other way to prevent this error from originating.

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

No branches or pull requests

2 participants