Socket send must be binary in Jython 2.7.3 (Ignition 8.1.35 and after)

I am prepping to upgrade a couple of systems from 8.1.19 to 8.1.37. Printing to Zebra printers has been giving me fits, getting an error message like:

TypeError: cannot make memory view because object does not have the buffer interface

I have a few places where I was writing strings to a socket and it accepted them before in 2.7.2 version Jython, but in 2.7.3 it gives the above error.

I sprinkle a few .encode("utf-8") s in to make it work.

So probably 2.7.3 is more strict about taking only binary. I don't think this is a bug, just wanted to put it on here to save the next person some time, cause it took a little while for me to hunt that down.

Here is more of the error:

"C:\Users\kmaze.ignition\cache\gwusatizwkit3001.na.bpww.org_8080\C0\pylib_socket.py", line 1461, in meth
return getattr(self._sock,name)(*args)
File "C:\Users\kmaze.ignition\cache\gwusatizwkit3001.na.bpww.org_8080\C0\pylib_socket.py", line 0, in sendall
TypeError: cannot make memory view because object does not have the buffer interface

Thanks

1 Like

Or, better, just don't use jython's sockets. Python 2.7's poor separation between strings and byte arrays, which jython has to work around, makes a mess of socket interfaces. Just learn to use use the java.net and/or java.nio. Really.

Thanks for this post, Ken. Made my troubleshooting a bit easier.

I had a similar issue after updating from v8.1.35 to v8.1.39 on the weekend. What I find strange about that though, is that Jython 2.7.3 was in v8.1.34 and I wasn't having these errors. Is anyone smarter than me able to shed light on why I only now had this?

The release notes for 8.1.35 state Jython was upgraded. But I don't know why you wouldn't have encountered the problem in 8.1.35 then

Just saved me hours of bashing my head against the wall

To avoid future misery:

Really.

In my defense I was just trying to patch up someone else's code to get it back working. And don't really have much experience with socket communication and what it entails. I'm just a hack

I would be glad to do that but there is no training for this that I see in the Inductive system, and I don't see a lot about it generally when I do some searching. Do you have a good source for training on this?

Thanks

Use java training materials, not python training materials.

And there are numerous topics here:

https://forum.inductiveautomation.com/search?q=java.net.Socket%20order%3Alatest