Comments (4)
Here is my client file. i need a small suggestion if my client is implemented good regarding with_tcp_transport() function.
from logging import addLevelName
import string
import random
from random import randint
from iec62056_21.client import Iec6205621Client
HOST = '127.0.0.1'
PORT = 8081
address = (HOST, PORT)
def int_generator(chars=range(0, 250000)):
"""Function to generate random integers with with specified size"""
return random.choice(chars)
#-----------------------------------------------------------------------#
Initialize Iec6205621Client instance with tcp
#-----------------------------------------------------------------------#
def Run_client():
client = Iec6205621Client.with_tcp_transport(address=(HOST, PORT))
print("socket created")
client.connect()
print("connected with server successfully")
number_of_data_to_send = 100
sent_data = 0
while(sent_data < number_of_data_to_send):
data = int_generator()
client.write_single_value(address=address, data=data)
sent_data+=1
client.disconnect()
print("client disconnected")
if name == "main":
Run_client()
from iec62056-21.
Hi.
You are getting a ConnectionRefusedError on the TCP connection. There is no service to receive your connection. If you are running them as docker containers I would assume that you have to reference the other containers IP or hostname, not the loopback interface 127.0.0.1
from iec62056-21.
Here is my server file. as you mentioned , my server here is accepting the service connection from client side. Can you provide some more idea, As you said there is no service to recieve my connection.
HOST = '127.0.0.1' # Standard loopback interface address (localhost)
PORT = 8081 # Port to listen on (non-privileged ports are > 1023)
address = (HOST, PORT)
recieved_data = []
ack = "\x06"
byte_ack = bytes(ack, 'utf-8')
#---------------------------------------------------------------------#
#initialising server to accept client connection
#---------------------------------------------------------------------#
def run_server():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
print("socket created")
server.bind((HOST, PORT))
server.listen()
print("waiting for connections")
print ('Listening on .... ', (HOST, PORT))
conn, address = server.accept()
with conn:
print('Successfully connected with', address)
while True:
data = conn.recv(1024)
# Stop loop if no more data is received
if not data:
break
recieved_data.append(data)
# Sending an ack in bytes to meter
conn.sendall(byte_ack)
print(recieved_data)
server.close()
print("server diconnected")
if name == "main":
run_server()
from iec62056-21.
If you are using docker you cannot use the loopback interface to bind the service on as this is not available outside of the container. You also need to set up correct port exposing for the container.
I'm gonna close this issue since it is related to docker and/or networking and not this library.
from iec62056-21.
Related Issues (20)
- switch baudrate HOT 3
- rest() from Iec6205621Client HOT 4
- read_single_value HOT 5
- ISk5MT174 - TimeoutError: Read in SerialTransport timed out HOT 3
- connecting via GSM HOT 11
- ZMD energy meter HOT 4
- Update Pypi HOT 9
- support protocol mode = 2 in AckOptionSelectMessage HOT 2
- Move to attrs classes for messages
- Request support for HAN-NVE (a.k.a. Norwegian RJ45 HAN-port standard) interface over M-Bus HOT 1
- Implementing protocol to my client file. HOT 5
- Socket Timeout HOT 3
- read 1.8.0
- Problem with client.read_value
- readout of landis + gyr120AP HOT 1
- trying to readout EMH - LZQJ-XC but cant build up connection HOT 9
- Not able to enter programming mode on EMH meter - serial transport
- EMH meter is only responding with ACK on read. HOT 1
- Not able to send address in init request over serial transport
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iec62056-21.