Home/Support/Support Forum/Cannot connect to echo server using python sample code
New and improved user forum site coming soon
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Cannot connect to echo server using python sample code

0 votes
We recently purchased a couple Digi XBee3 Cell LTEM/NBIOT development kits, have installed SIM cards in each and have connectivity.

I ran through the sample application to talk to the echo server at https://www.digi.com/start/xbee3-cellular-lte-m-nosim using XCTU and it worked great on both kits, response from your echo server was received.

I am now trying to write an application (using python 3.8) to send data using a python file but I get errors following your various different forum and samples.
I have the following python file code I got from your site.

The XBEE has been set to AP mode 1

from digi.xbee.devices import CellularDevice
from digi.xbee.models.protocol import IPProtocol
from ipaddress import IPv4Address
device = CellularDevice("COM24", 9600)
device.send_ip_data(IPv4Address(""), 11001, IPProtocol.TCP, "Hello XBee World!")
ip_message = device.read_ip_data()
print(ip_message.data.decode("utf8") if ip_message is not None else "ERROR")

It gives the error after running in command line python
C:\PythonTesting>py connect.py
Traceback (most recent call last):
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\site-packages\digi\xbee\reader.py", line 1351, in get
return Queue.get(self, True, timeout)
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\queue.py", line 178, in get
raise Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "connect.py", line 26, in <module>
ip_message = device.read_ip_data()
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\site-packages\digi\xbee\devices.py", line 1584, in dec_function
return func(self, *args, **kwargs)
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\site-packages\digi\xbee\devices.py", line 4667, in read_ip_data
return self.__read_ip_data_packet(timeout)
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\site-packages\digi\xbee\devices.py", line 4727, in __read_ip_data_packet
packet = queue.get(timeout=timeout)
File "C:\Users\rob.s\AppData\Local\Programs\Python\Python38-32\lib\site-packages\digi\xbee\reader.py", line 1353, in get
raise TimeoutException()
digi.xbee.exception.TimeoutException: There was a timeout while executing the requested operation.

Can anyone point me in any direction? What we really need it to do is to be able to send a small data packet from a connected computer to the XBEE cellular, then have that XBEE send to a second XBEE a thousand miles away and be able to read the data from another computer connected to the remote XBEE.But i can't even get this simple send working.

Thank you for any help I have been at this for a week!
asked Jul 23, 2020 in Digi Connect Cellular by AthenaIndustrial New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
All of the sample code Digi provides needs the radios to be using API mode.
answered Jul 23, 2020 by mvut Veteran of the Digi Community (15,515 points)
Got it working, needed to make sure I was in the right mode and have each XBEE on the correct cellular network. Thanks!!