# \[Slightly OT\] Dealing with lost connections

**URL:** <https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566>\
**Category:** Rails\
**Created:** [July 24, 2006, 4:39am UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566 "2006-07-24T04:39:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [July 24, 2006, 4:39am UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566/1 "2006-07-24T04:39:04Z")

</div>

Hi! I know that the web is essentially stateless, so I was wondering  
about how lost connections can be managed.

I have an application that posts data to a web form. This form has a  
large number of items (about 38) and I’m a bit concerned about the  
connection being lost while posting the data. Is it safe to assume that  
the web application will reject the transmission if the right number of  
data bytes is not received from the client? (The POST header stores the  
length of the content)

Is there anything else that I can do to make it robust?

Thanks  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [July 24, 2006, 12:38pm UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566/2 "2006-07-24T12:38:22Z")

</div>

Simply do validation on the inputs. If all 38 of them are supposed  
to be there, then use validates\_presence\_of, and return the page to  
the user to fix if something’s missing. But to your underlying  
question, the user hitting submit twice after not getting a quick  
response is a much, much bigger issue than POSTs getting cut off  
during transmission.

```
        - dan

```

–  
Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [July 24, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566/3 "2006-07-24T18:19:59Z")

</div>

I still see lots of sites say “Please only click once”. You really  
don’t want to move the essential questions to the bottom. That’s bad  
UI design. If you’re so worried about partial forms, create a 39th  
hidden field at the bottom, and the validate for the presence of that  
one.

```
        - dan

```

–  
Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [July 24, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566/4 "2006-07-24T15:42:40Z")

</div>

Dan K. wrote:

> Simply do validation on the inputs. If all 38 of them are supposed to  
> be there, then use validates\_presence\_of, and return the page to the  
> user to fix if something’s missing. But to your underlying question,  
> the user hitting submit twice after not getting a quick response is a  
> much, much bigger issue than POSTs getting cut off during transmission.
> 
> ```
> - dan
> 
> ```
> 
> –Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

Hi Dan,

Thanks for the pointers… a number of those parameters are not  
essential, but I can move the essential parameter to the end of the list  
and use validates\_presence\_of on that parameter to try to ensure that it  
seems to be working!

As for submitting twice, in this specific application, I don’t have to  
worry too much about that since the submission is being done  
automatically by my own program and I can control that to some extent  
🙂 What is the general practice to avoid having double submissions? I  
notice that some of my preferred sites use Javascript to disable the  
button once submit has been clicked… if JS is disabled, then that  
doesn’t work (but I guess they assume that most people who disable JS  
themselves know better than to submit it twice!)

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [July 24, 2006, 6:36pm UTC](https://www.ruby-forum.com/t/slightly-ot-dealing-with-lost-connections/99566/5 "2006-07-24T18:36:27Z")

</div>

Dan K. wrote:

> I still see lots of sites say “Please only click once”. You really  
> don’t want to move the essential questions to the bottom. That’s bad  
> UI design. If you’re so worried about partial forms, create a 39th  
> hidden field at the bottom, and the validate for the presence of that  
> one.
> 
> ```
> - dan
> 
> ```
> 
> –Dan K. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000  
> Hi Dan,

As always, thanks for the good advice… It’s a good point that we  
should not move the essential items to the bottom… but, like I said,  
in my case, the form is submitted automatically by a piece of software.  
So, I have the flexibility to format the POST string to place the item  
right at the end irrespective of the position of the question in the  
UI. (In fact, in my case, the user will not often see the data before  
it is submitted) 🙂

But, I appreciate your concern and I do agree the hidden field makes a  
nice simple option!  
Cheers  
Mohit.
