I am trying to send a message to my websocket server but I keep getting this error.

Traceback (most recent call last):
  File "send.py", line 5, in <module>
    ws = websocket.create_connection("ws://ipaddress:9001")
AttributeError: 'module' object has no attribute 'create_connection'

I created a python server file server is started but when I send a message I get this error what could be the problem.

here is the code itself

import websocket
import sys
val = sys.argv[1]
ws = websocket.create_connection("ws://ipaddress:9001")

Recommended Answers

All 5 Replies

You could perhaps start with an example similar to the "getting started" part of the websocket documentation

i checked that now not really helping, i had this problem before and solved it, just can't remember what I did Ive been checking packages. Just for confirmation wat packages do you absolutely need to run websockets

plus that example uses python higher than my current version i m on python 2.7.3

According to the documentation, the module requires a python version >= 3.4. I'm afraid it won't run on your python 2.7. I hope somebody else can help you because I never used this module.

found the problem

pip uninstall websocket
pip install websocket-client

The websocket package was causing problems (conflicts)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.