Django TCP Socket Communication

779 views
Skip to first unread message

bobdxcool

unread,
Mar 27, 2015, 3:47:38 PM3/27/15
to django...@googlegroups.com
I am new to TCP socket programming. I have a django based server
communicating with a microcontroller. Now, I want to implement TCP based
socket on the server side in order to communicate with the TCP socket on the
microcontroller. Can anyone give me an idea on how to do this ? What
libraries should I use on my django server The microprocessor basically
opens the socket every 5 seconds and sends a notification to the server. I
on the server side should be able to read this and pump data back to the
microprocessor using this socket which was opened by the microprocessor.



--
View this message in context: http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html
Sent from the django-users mailing list archive at Nabble.com.

François Schiettecatte

unread,
Mar 27, 2015, 3:55:37 PM3/27/15
to django...@googlegroups.com
Have you looked at the ‘socket’ python library ?

François
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1427483125637-5090792.post%40n6.nabble.com.
> For more options, visit https://groups.google.com/d/optout.

bobdxcool

unread,
Mar 28, 2015, 6:06:43 AM3/28/15
to django...@googlegroups.com
But is that compatible with django ?

On Sat, Mar 28, 2015 at 1:24 AM, François Schiettecatte [via Python] <[hidden email]> wrote:
Have you looked at the ‘socket’ python library ?

François

> On Mar 27, 2015, at 3:05 PM, bobdxcool <[hidden email]> wrote:
>
> I am new to TCP socket programming. I have a django based server
> communicating with a microcontroller. Now, I want to implement TCP based
> socket on the server side in order to communicate with the TCP socket on the
> microcontroller. Can anyone give me an idea on how to do this ? What
> libraries should I use on my django server The microprocessor basically
> opens the socket every 5 seconds and sends a notification to the server. I
> on the server side should be able to read this and pump data back to the
> microprocessor using this socket which was opened by the microprocessor.
>
>
>
> --
> View this message in context: http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792.html
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



If you reply to this email, your message will be added to the discussion below:
http://python.6.x6.nabble.com/Django-TCP-Socket-Communication-tp5090792p5090799.html
To unsubscribe from Django TCP Socket Communication, click here.
NAML



View this message in context: Re: Django TCP Socket Communication

Gergely Polonkai

unread,
Mar 28, 2015, 9:51:24 AM3/28/15
to django...@googlegroups.com

Hello,

it's a bit hard to understand what you exactly want to achieve. How can you communicate with the microcontroller? Do you connect to one of its TCP ports, and send it data, I assume. Is it done with a well-known protocol, like HTTP, or some custom one?

You say that it opens a port every 5 seconds to a server. Where is that server? Is it on the same machine as you Django based application? How does the microcontroller and the server communicate with each other?

There are so many architectural questions here before you get to a web application, and I'm afraid you original question cannot be answered before we see the whole picture.

Best,
Gergely

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

bobdxcool

unread,
Mar 28, 2015, 10:14:03 AM3/28/15
to django...@googlegroups.com

it's a bit hard to understand what you exactly want to achieve. How can you communicate with the microcontroller? Do you connect to one of its TCP ports, and send it data, I assume. Is it done with a well-known protocol, like HTTP, or some custom one?


Yes, one of the TCP port on the micro-controller is connected to and data is sent via this to the server.

You say that it opens a port every 5 seconds to a server. Where is that server? Is it on the same machine as you Django based application? How does the microcontroller and the server communicate with each other?

The server is django based one. I still need to implement the communication part on the server side. Need suggestion on how to do this using TCP sockets.




On Sat, Mar 28, 2015 at 7:20 PM, Gergely Polonkai [via Python] <[hidden email]> wrote:

Hello,

it's a bit hard to understand what you exactly want to achieve. How can you communicate with the microcontroller? Do you connect to one of its TCP ports, and send it data, I assume. Is it done with a well-known protocol, like HTTP, or some custom one?

You say that it opens a port every 5 seconds to a server. Where is that server? Is it on the same machine as you Django based application? How does the microcontroller and the server communicate with each other?

There are so many architectural questions here before you get to a web application, and I'm afraid you original question cannot be answered before we see the whole picture.

Best,
Gergely

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



If you reply to this email, your message will be added to the discussion below:
To unsubscribe from Django TCP Socket Communication, click here.
NAML

Anil reddy reddy M

unread,
Jun 16, 2016, 7:06:23 AM6/16/16
to Django users
Hi,

 I made a TCP Server Socket  programming in python, it's nicely communicating with micro controller, and also i can store latitude ,longitude values in MySqldb from GPS output. Now I want develop a web application for vechile  tracking. How can i do this stuff in django.  I would be thankful   for all  the help i can get! 

Jani Tiainen

unread,
Jun 16, 2016, 7:35:18 AM6/16/16
to django...@googlegroups.com
Hi,

So if I understood correctly you want to use microcontroller to connect Django web-app periodically.

One "easy" option would be using HTTP protocol to talk to Django and then use simple RESTful calls to push your data.

Of course that all depends what kind of libraries your microcontroller does have for communication.

If you do not have HTTP protocol luxury but something more primitive, you need to build some kind of middleware server that can understand incoming data from your microcontroller and then push it to Django server.

But there is no easy way to push arbitrary data through TCP socket to Django server directly - Django is mainly build around HTTP request - response cycle.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Jani Tiainen

Jani Tiainen

unread,
Jun 16, 2016, 7:38:12 AM6/16/16
to django...@googlegroups.com
Oops, apparently you hijacked over year old thread...

On 16.06.2016 13:45, Anil reddy reddy M wrote:
Hi,

 I made a TCP Server Socket  programming in python, it's nicely communicating with micro controller, and also i can store latitude ,longitude values in MySqldb from GPS output. Now I want develop a web application for vechile  tracking. How can i do this stuff in django.  I would be thankful   for all  the help i can get! 



Just make models to match tables and then use Django as you wish. There isn't nothing magical there.

For starting point you can use inspectdb to create initial models from your database which you then can refine to suit your needs.

Sergiy Khohlov

unread,
Jun 16, 2016, 7:42:52 AM6/16/16
to django-users
Have ready  this kind of application  using  django + postgis. At this moment protocols Cabon and teltronika are supported. Are you interested ? 

Many thanks,

Serge


+380 636150445
skype: skhohlov

CLIFFORD ILKAY

unread,
Jun 16, 2016, 3:57:41 PM6/16/16
to django...@googlegroups.com
On 16/06/16 07:34 AM, Jani Tiainen wrote:
But there is no easy way to push arbitrary data through TCP socket to Django server directly - Django is mainly build around HTTP request - response cycle.

That is no longer true. Django Channels makes this dead easy.

We're using Django Channels in a control panel for Debian virtual machines. The user provides some basic configuration options for the AngularJS/Node.js application running within the VM, such as database auth info, networking info, etc. On save of the singleton MachineConfig object, we also save the same key/value pairs into a YAML file. There is a daemon that is running inotifywait monitoring that YAML file for changes and when it detects a change, it kicks off "salt-call --local ..." to have SaltStack configure the VM as per the key/value pairs in the YAML file. As Salt progresses through the various states, it sends a progress message on a WebSocket. Django is listening for those messages and displays them in an overlay that masks the page content below it on the control panel to provide an indication to the user what is happening inside the VM. When Salt has run through all the states and configured the VM, it sends a "Finished Configuring Machine" which is displayed for a few seconds and then hidden. The user then has access to the control panel again in case they want to change something later or restart the VM.

You can read more about Django Channels in a blog post by Jacob Kaplan-Moss. My understanding is that Channels will be integrated in Django core at some point.
-- 
Regards,

Clifford Ilkay

+ 1 647-778-8696

Anil reddy reddy M

unread,
Jun 17, 2016, 1:16:21 AM6/17/16
to Django users
How i can store gps output in django model, how django will communicate  with micro controllar

Sergiy Khohlov

unread,
Jun 17, 2016, 3:31:35 AM6/17/16
to django-users

Simple script receives data from GPS tracker and stores data into database. Django has geodjango application for plotting point at the map.

17 черв. 2016 08:16 "Anil reddy reddy M" <anilre...@gmail.com> пише:

Anil reddy reddy M

unread,
Jul 9, 2016, 2:58:37 AM7/9/16
to Django users
Hi,
Yeah, I am ready

Anil reddy reddy M

unread,
Jul 9, 2016, 3:05:21 AM7/9/16
to Django users
And I want use Celery with rabbitmq Broker in this process.
Reply all
Reply to author
Forward
0 new messages