[Solved]A socket error occurred when sending the command python

I want to connect to my bulb using python with this code, but there is problem :

import socket

msg = 'M-SEARCH * HTTP/1.1\r\n' \
	      'ST:wifi_bulb\r\n' \
	      'MAN:"ssdp:discover"\r\n'

# Set up UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.settimeout(10)
s.sendto(msg.encode(), ('239.255.255.250', 1982))

print(s.recvfrom(65507))

Traceback (most recent call last):
  File "/home/ali/a.py", line 12, in <module>
	print(s.recvfrom(65507))
socket.timeout: timed out

Any other command had this problem (yeelight.main.BulbException: A socket error occurred when sending the command.)

Please download our Linux version demo (which is written in Python) and try.

thanks for answer, but this line of code with your demo code with python is same logic and same syntax !
please help me if you can find out that what is the problem of my discover method that can not find any bulb with broadcast message !?!

thx.

The problem is your code didn’t get any response within 10 seconds and raise an exception. Are you sure you have opened the developer mode of the bulb?
You can use our demo to test, if our demo is working, it’s your code’s issue, otherwise, you need to find out why response is not received.

Exactly ! there is no developer option in my mi app !
I use your demo and result is same !
I think this is the problem, how can i enable developer mode when there is no option in my app ?
How can i reset to factory my bulb ?

Thanks for your answer.

https://www.yeelight.com/en_US/developer

No need to reset bulb.

I download the app and add device and there is no developer option in my setting page !
where is this option ?
this is my setting menu :
https://drive.google.com/open?id=0B392wMr_wQ1HLVl1aDYteUg0V28

and i have another question for you: how to reset to catory my bulb ?

You need to search and download “Yeelight” app in App store. This is Mijia App not Yeelight.

Yap ! this is original app ! but the QR code in bulb catalog download mi app for me !
Thanks. problem solved perfectly and solution is download “Yeelight” app in App store and activate developer mode from settings.

OK. We will change the QR code.

How can I open the development mode ?