2

I am trying to create a secure connection to Money.net API using user id and pwd but I am not getting any response back from server. I am using Ipython Notebook for development and I am new to world of Programming and Python :)

import socket
import sys
Server_address = ('api.data.money.net',50010)
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print sys.stderr, 'connecting to %s port %s' %Server_address
s.connect(Server_address)
####### I pass plain text authentication credentials below #####
username, password, DATA

Nothing happens and server doesn't respond back with 'OK' as expected

I also tried TLS socket.wrap method below but it says "connection timed out"

import socket
import ssl

# SET VARIABLES
#packet, reply = "QS MSFT", ""
HOST, PORT = 'api.data.money.net', 50010

# CREATE SOCKET
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(30)

# WRAP SOCKET
wrappedSocket = ssl.wrap_socket(sock,keyfile=None,server_side=0,
                            ssl_version=ssl.PROTOCOL_TLSv1,                                    cert_reqs=ssl.CERT_NONE,do_handshake_on_connect=True)


# CONNECT AND PRINT REPLY
wrappedSocket.connect((HOST, PORT))


#Plain Text authentication
'username','password'

I get the response

'username','password'

Then i execute the following

packet,reply="QS MSFT",""
wrappedSocket.send(packet)
print wrappedSocket.recv(1280)

I get the following error in the end

SSLError: ('The read operation timed out',)
4
  • Can you provide a link to the documentation for this API? Also, I don't any code here to create a "secure" connection. Commented Mar 8, 2017 at 20:14
  • Hi James - The link is as follows money.net/datafeed Commented Mar 8, 2017 at 20:19
  • So, like @Jean-Paul suggested, the docs say "...You must connect using TLS. Our server will present a TLS certificate for *.data.money.net...". You should look at the python ssl module Commented Mar 8, 2017 at 20:22
  • @James - I tried connecting via TLS, however I am still getting above error. Commented Mar 8, 2017 at 22:06

1 Answer 1

1

I would expect an API to be exposed over internet using https rather than sockets. Are you sure you have to go that way?

There are a lot of packages to make a secure call with basic authentication. The requests packages is higher level and used in many projects, so that would be your safest bet.

Note that early versions of these libraries simply ignored certificate verification, if it has to be really secure make sure you.

Look at the answers at Python, HTTPS GET with basic authentication.

Sign up to request clarification or add additional context in comments.

1 Comment

As per their www.money.net/datafeed document "Note: If you are using a proxy server on your network, our system requires either a standalone SOCKS proxy or a SOCKS proxy in combination with a web proxy. A web proxy which only handles HTTP and HTTPS traffic will not work as our market data connection uses a proprietary TCP protocol that is not compatible with the HTTP protocol. " However as shown above i did try TLS connection using socket wrap but it didnt work too :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.