Concatenated URLConnection.Send

  1. 7 weeks ago

    Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Germany

    I am trying to concatenate URLConnection.Send's.

    I've made a Subclass of URLConnection and added Methods for various (PUT,GET,POST) Tasks.
    In the ContentReceived Event of my Subclass i am checking the HTTPStatus and the content and as a result, may call then another Method within my Subclass which in turn do a Send again.

    But i get always a "A request is already in progress" exception. I thought the ContentReceived Event will fire when the content has been received and i can do a new Send?

    @Paul L You probably need the ContentReceived event to actually finish before you can call Send again. Maybe try using a Timer to kick off the Send instead?

    @Paul L : Thank you. That did it! :)

    I added a Xojo.Core.Timer Private Property called SocketTimer to the Subclassed Socket.
    Then added a sender As Xojo.Core.Timer as Parameter to my Methods.

    Now i can Do a

    SocketTimer = New Xojo.Core.Timer
    SocketTimer.Mode = Xojo.Core.Timer.Modes.Single
    SocketTimer.Period 250 // Needs tuning...
    AddHandler SocketTimer, AddressOf myMethodName
  2. Tim P

    Jan 30 Pre-Release Testers feedback://46303

    I would be that there's a flag that gets unset after the event. However, for reliability it has been recommended multiple times to not re-use a socket. If necessary I build a queuing system with a module.

  3. Paul L

    Jan 30 Xojo Inc http://docs.xojo.com

    You probably need the ContentReceived event to actually finish before you can call Send again. Maybe try using a Timer to kick off the Send instead?

  4. Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Germany

    @Tim P I would be that there's a flag that gets unset after the event. However, for reliability it has been recommended multiple times to not re-use a socket. If necessary I build a queuing system with a module.

    I know, but sometimes it makes sense for various reasons. But you just need to be extra carefull. ;)

  5. Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Germany

    @Paul L You probably need the ContentReceived event to actually finish before you can call Send again. Maybe try using a Timer to kick off the Send instead?

    I'll try it. Tried to avoid the extra overhead until now. :)

  6. Tim P

    Jan 30 Pre-Release Testers feedback://46303

    @SaschaSchneppmueller I know, but sometimes it makes sense for various reasons. But you just need to be extra carefull. ;)

    In my opinion, to be extra careful you would create a new socket and request and add it to the queue.

  7. Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Germany

    @Tim P In my opinion, to be extra careful you would create a new socket and request and add it to the queue.

    But each new Socket would need to connect and re-authenticate, or? Could be getting slow with 8.000 POST's. :D

  8. Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Answer Germany
    Edited 7 weeks ago

    @Paul L You probably need the ContentReceived event to actually finish before you can call Send again. Maybe try using a Timer to kick off the Send instead?

    @Paul L : Thank you. That did it! :)

    I added a Xojo.Core.Timer Private Property called SocketTimer to the Subclassed Socket.
    Then added a sender As Xojo.Core.Timer as Parameter to my Methods.

    Now i can Do a

    SocketTimer = New Xojo.Core.Timer
    SocketTimer.Mode = Xojo.Core.Timer.Modes.Single
    SocketTimer.Period 250 // Needs tuning...
    AddHandler SocketTimer, AddressOf myMethodName
  9. Tim P

    Jan 30 Pre-Release Testers feedback://46303

    @SaschaSchneppmueller But each new Socket would need to connect and re-authenticate, or? Could be getting slow with 8.000 POST's. :D

    What kind of authentication? The don't re-use sockets note comes from engineer posts on the forum :/

  10. Sascha S

    Jan 30 Pre-Release Testers, Xojo Pro Germany
    Edited 7 weeks ago

    @Tim P What kind of authentication? The don't re-use sockets note comes from engineer posts on the forum :/

    Currently only Basic (Name/Password) auth. But will be certificate secured when the servers go live.

    I Subclassed a URLConnection which needs to Auth with the Server. And i think each new Socket needs to authenticate before it can communicate with the Server?

    In my case, i need to transfer thousands of customers, contacts and Phonenumbers from mySQL Databases to sip:wise Servers using HTTPS and JSON. There can be more than 8.000 Phonenumbers in one App Session needed to be transferred. This would take a few hours (more) if i would have to re-authenticate each "Check if Customer exist, check if Contact exist, Create Contact, Create Customer, Create Subscribers" cycle. :D

  11. 5 weeks ago

    Jonathan E

    Feb 11 Pre-Release Testers, Xojo Pro Las Vegas, NV

    Would this, by chance, be a good use-case for a thread and Semaphore ?

  12. Sascha S

    Feb 11 Pre-Release Testers, Xojo Pro Germany

    @Jonathan E Would this, by chance, be a good use-case for a thread and Semaphore ?

    Thank you @Jonathan E

    Maybe, but my current solution works just fine and it's just a workaround for a Bug in URLConnection which has been fixed for a future release. :)

  13. Jonathan E

    Feb 12 Pre-Release Testers, Xojo Pro Las Vegas, NV

    @SaschaSchneppmueller Thank you @Jonathan E

    Maybe, but my current solution works just fine and it's just a workaround for a Bug in URLConnection which has been fixed for a future release. :)

    I saw that you had this all sorted out. I was just wondering if this would work since I have yet to actually use one!

  14. Sascha S

    Feb 12 Pre-Release Testers, Xojo Pro Germany

    @Jonathan E I saw that you had this all sorted out. I was just wondering if this would work since I have yet to actually use one!

    I am sorry to say this but i cannot recommend to use URLConnection in it's current state. There are more issues other reported in the Feedbacks. But my project is nearly finished and i need to move on. :)

    If i should recommend a solution i would recommend to use the CURL Addon by MBS. It's far more capable and issues will be fixed by @ChristianSchmitz in very short time.

or Sign Up to reply!