B4J Tutorial [Server] Upload files from your B4A app to your B4J server over the internet

Discussion in 'B4J Tutorials' started by Erel, Jan 28, 2014.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

  2. YIM bunchhat

    YIM bunchhat Active Member Licensed User

    hello,...I tested but it doesn't work. when I start server on PC I got : Update DuckDNS: OK, when I test with your example I got Update DuckDNS: KO. When I send string form phone I got error. I already configure router port forward and open firewall. what's wrong? I use router TP-link
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Can you access the server if you use the ip address instead of the dynamic host name?
     
  4. YIM bunchhat

    YIM bunchhat Active Member Licensed User

    Hello I still cannot. I follow you by ip address I got as picture below. I configure my router like this is it correct? Untitled.png

    On this point what you means and how to do it? call handle we need to add code to Main or not? Sorry I am new with coding
     

    Attached Files:

    Last edited: Oct 13, 2015
  5. Erel

    Erel Administrator Staff Member Licensed User

    It has nothing to do with the code.

    The service port should probably be 54021 as well.
     
  6. YIM bunchhat

    YIM bunchhat Active Member Licensed User

    Here is your sample I modify it only on domain and token is it correct?
    Code:
    Non-UI application (console application)
    #Region  Project Attributes
        
    #CommandLineArgs:
        
    #MergeLibraries: False
    #End Region

    Sub Process_Globals
        
    Private domain As String = "chhat"
        
    Private token As String = "07d52e48-f68a-4b47-85e8-1d7b7834106c"
        
    Private updateIp As Timer
        
    Private srvr As Server
        
    Public filesFolder As String = "uploaded"
    End Sub

    Sub AppStart (Args() As String)
        updateIp.Initialize(
    "updateIp"60 * 1000'10 minutes
        updateIp.Enabled = True
        UpdateIp_Tick
        srvr.Initialize(
    "srvr")
        srvr.Port = 
    54021
        
    File.MakeDir(File.DirApp, filesFolder)
        srvr.AddHandler(
    "/upload""Upload"False)
        srvr.AddHandler(
    "/test""Test"False)
        srvr.Start
        
    Log("Server started")
        StartMessageLoop
    End Sub

    Sub UpdateIp_Tick
        
    Dim j As HttpJob
        j.Initialize(
    "j", Me)
        j.Download2(
    "http://www.duckdns.org/update"Array As String("domains", domain, "token", token, _
            
    "ip"""))
    End Sub

    Sub JobDone (j As HttpJob)
        
    If j.Success = True Then
            
    Log("Update DuckDNS: " & j.GetString)
        
    Else
            
    Log("Error updating Duck DNS: " & j.ErrorMessage)
        
    End If
        j.Release
    End Sub
     
  7. YIM bunchhat

    YIM bunchhat Active Member Licensed User

    I test with browser and got like this Untitled.png
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The problem is in the network configuration.

    Have you opened this port in Windows firewall?
     
  9. YIM bunchhat

    YIM bunchhat Active Member Licensed User

    yes I open it....to open it I follow as in CCTV right?
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Yes.

    If you still wasn't able to solve it then please start a new thread in the questions forum.
     
  11. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Can server download file from internet and send it to client ?
    I am thinking of making a small proxy .
    What I tried is getting url from client in a handler class then download the file (http job) when job finishes I use File.Copy2(job.GetInputStream , ...) to write to resp.OutputStream .
    But as you can see Sub Handle(req As ServletRequest, resp As ServletResponse) should have finished at that time
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    The answer is yes. Please start a new thread and I'll explain it.
     
  13. nonno

    nonno Active Member Licensed User

    Erel devo inviare un file txt di piccola dimensione tramite wifi da cellulare al pc
    non riesco potresti darmi dei consigli( non sono programmatore conosco abbastanza il linguaggio VB6)
    Grazie mille
     
  14. HAH

    HAH Active Member Licensed User

    Hi
    We are connected to internet through ADSL from ourl local ISP.
    Our local ISP NAT-ing us, for example:
    If i connected to the internet; my adsl modem got this ip 10.33.19.74 but if i checked my ip in google i got this different ip 109.200.183.132
    From internet outside of my adsl i can't connected to our local server by following the above roles !

    Any suggestion please ...
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    This is called carrier grade NAT (CGN). You will not be able to connect to your computer from outside unless your ISP provides you a real and unique IP address.

    You should contact your ISP.
     
  16. HAH

    HAH Active Member Licensed User

    Our ISP doesn't respond to us!
    Can we work around it?
    when i using teamviewer, it work fine, Is their any solution exists like teamviewer ?
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    I don't think that there is any simple workaround. TeamViewer is probably using an external server (maybe VPN).
     
  18. HAH

    HAH Active Member Licensed User

  19. Erel

    Erel Administrator Staff Member Licensed User

    Have you read it? There is an external server included in the solution.
     
  20. HAH

    HAH Active Member Licensed User

    Yes, i read it, it requires external server.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice