Declare your socket variable in the Activity script page instead of in the test page.
If you are leaving the activity and returning back to a page inside, then that is your problem as Prontoscript is shutdown upon leaving an activity (that is, it is not global to the remote, but rather activity-centric).