Roberto De Ioris <roberto@...> writes:
>
>
> > Hi,
> >
> > I'd like to get a simple "hello world" example working as a UDP server. I
> > could really use a little help.
> >
> > I am beginning with the examples/simple_logger.py sample code.
> > I have a very simple client running in a loop which sends a UDP message to
> > the server every few seconds.
> >
> >
> > ...My code looks like this:
> >
> > import uwsgi
> >
> > print('\n\n --- This prints just fine ---\n\n')
> >
> > def app(ip, port, message):
> > print('\n\n --- Wish this would print ---\n\n')
> > return True
> >
> > uwsgi.udp_callable = app
> >
> >
> > ...My ini file looks like this:
> >
> > [uwsgi]
> > plugins = python
> > socket = /tmp/metre.sock
> > no-default-app = true
> > module = example.app:app
> > udp = :5000
> > callable = app
> > show-config = true
> > vacuum = true
> >
> >
> > ...I am running uwsgi version 2.0.1 with this command:
> > $ uwsgi --ini example.ini
> >
> >
> > The server launches and runs without errors. I can see the print
> > statement
> > "This prints just fine", and a message "WSGI callable selected", so the
> > python module is at least being loaded.
> >
> > I can see the messages sent from the client written to std out by the
> > server
> > (although they are not printed by my code).
> >
> > What I am *unable* to do is get the "app" function called.
> >
> > Could anyone offer a suggestion what I might try?
> >
> > Thank you very much.
> >
> > _______________________________________________
> > uWSGI mailing list
> > uWSGI@...
> > http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
> >
>
> The udp higher-level management has been removed in 1.9/2.0 as running
> custom code in the master is too dangerous (obviously the plugin hook has
> not been removed, so users are free to attach to the udp socket in the way
> they need/want)
>
> Having said that, the real reason for removing it is that technically
> there is no need to this abstraction for logging purposes. Just spawn a
> thread (or a mule) to manage incoming udp packets.
>
> Check the second example you can simply load it in a mule:
>
> https://wiki.python.org/moin/UdpCommunication
>
Thanks alot for the info. Using a mule, I have "hello world" with UDP
working as follows:
$ cat example.ini
[uwsgi]
plugins = python
socket = /tmp/app.sock
no-default-app = true
udp = true
mule = /<path>/app.py
show-config = true
vacuum = true
$ cat /<path>/app.py
import uwsgi
import socket
print('\n\n --- Using {} ---\n\n'.format(globals()['__file__']))
UDP_IP = '127.0.0.1'
UDP_PORT = 5000
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024)
print('MULE #{0} received message: {1}'.format(uwsgi.mule_id(), data))
$ uwsgi --ini example.ini
...Thanks again!
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi