Unable to use python logger remotely using socket, but works on localhost -


i using logging utility on local network log data 1 python script another. server , client scripts works on same machine, not work different machine.

the client script snippet, running on ip "192.168.1.9" is-

import logging, logging.handlers  rootlogger = logging.getlogger('') rootlogger.setlevel(logging.debug) sockethandler = logging.handlers.sockethandler('192.168.1.10', 50005) 

the server script snippet, running on ip "192.168.1.10" locally -

def __init__(self, host='localhost', port=50005, handler=logrecordstreamhandler):     socketserver.threadingtcpserver.__init__(self, (host, port), handler) 

when run this, both client , server unresponsive, if no message ever sent.

my iptables empty (default), , there nothing except simple switch between 2 machines on network. can remotely use mysql fine. basic tcp socket connection @ random open port worked fine. going wrong here? logger code above, or entirely different networking reason?

when construct socketserver.tcpserver, (host, port) gets passed socket.socket.bind.

the socket programming howto explains bit means, short version point of specifying host tell listener socket interface(s) listen to. resolves name address, asks os interface owns address, , listens interface.


i'll use macintosh example here, details pretty same anywhere, except slight differences in names.

'localhost' resolves '127.0.0.1', belongs interface named 'lo0', "loopback" interface, listens nothing connections same machine on localhost address.

'192.168.1.10' belongs interface named 'en0', ethernet adapter listens coming on ethernet port. so, that's why works you. it's still not (probably) want.

'0.0.0.0' special address belongs every interface. may want.


but notice specifying ipv4 address—even '0.0.0.0'—means, @ least on platforms, you'll listen ipv4 connections. if want handle ipv6 well, how do that? well, can't on all platforms, on can, it's ''.

(on platforms, still won't work ipv6; need create ipv6 , ipv4 sockets, , bind them specific ipv6 , ipv4 "any" addresses separately. on such platforms, python still lets use '' both "any" addresses, , default socket ipv4, work-case scenario, works '0.0.0.0'.)


so, likely, want:

def __init__(self, host='', port=50005, handler=logrecordstreamhandler): 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -