Interesting, can you expose the server URL so we can run this test case and 
see?

On Friday, March 12, 2021 at 10:57:24 PM UTC+2 [email protected] wrote:

> I switched to using Util.readToString() and still no joy on the iphone 
> device.
> The code still works ok on the simulator and on also on a real Android 
> device.
>
> On Wednesday, March 10, 2021 at 10:28:42 PM UTC-5 Shai Almog wrote:
>
>> Try using String ans = Util.readToString(); which might be better. 
>> Is the code still working on the simulator after the changes?
>> Is it working on Android?
>>
>> On Wednesday, March 10, 2021 at 5:09:18 PM UTC+2 [email protected] wrote:
>>
>>> Replacing flush() with close() didn't make a difference. Here's the code 
>>> I used without the buffer:
>>>
>>> os = link.getOutputStream();
>>> os.write((nemail + "\n").getBytes());
>>> pwHash = getHash(nemail + npasswd);
>>> os.write((pwHash + "\n").getBytes());
>>> os.close();
>>>
>>> is = link.getInputStream();
>>> String ans = readLine(is);
>>>
>>> static String readLine(InputStream stream) {
>>>     byte[] b = new byte[80];
>>>     String s = "";
>>>     int i = 0;
>>>     try {
>>>         b[i] = (byte) stream.read();
>>>         while((b[i] != 10 && (b[i] != 13))) {
>>>             i++;
>>>             b[i] = (byte) stream.read();
>>>         }
>>>         b[i] = 0;
>>>        return new String(b,0,i);
>>>     } catch(IOException e) {
>>>         Log.e(e);
>>>         return null:
>>>     }
>>> } 
>>> On Tuesday, March 9, 2021 at 10:23:18 PM UTC-5 Shai Almog wrote:
>>>
>>>> Can you include the full code after removing the buffers?
>>>> Also try replacing flush() with close(). That might help.
>>>>
>>>> On Tuesday, March 9, 2021 at 3:31:25 PM UTC+2 [email protected] wrote:
>>>>
>>>>> I'm able to access all the websites on that IP from the device. I also 
>>>>> tried accessing the reply from the server without the BufferedInputStream 
>>>>> with no luck.
>>>>>
>>>>> The certificate I used was one I bought from bluehost.com who hosts 
>>>>> my server.
>>>>>
>>>>> On Monday, March 8, 2021 at 9:51:04 PM UTC-5 Shai Almog wrote:
>>>>>
>>>>>> With valid (not self signed) certificate?
>>>>>> Is it a publicly visible IP accessible from the device?
>>>>>>
>>>>>> On Monday, March 8, 2021 at 8:35:52 PM UTC+2 [email protected] wrote:
>>>>>>
>>>>>>> Yes, the site is https. To make sure, I tested it using the Qualys 
>>>>>>> ssl checker and I access it with the https:// prefix.
>>>>>>>
>>>>>>> --Dennis
>>>>>>> On Sunday, March 7, 2021 at 9:42:05 PM UTC-5 Shai Almog wrote:
>>>>>>>
>>>>>>>> I meant the Rest class.
>>>>>>>>
>>>>>>>> Sorry I neglected to ask something basic. Is the URL HTTPS?
>>>>>>>> If not iOS will fail by default. You can use this as a workaround: 
>>>>>>>> https://www.codenameone.com/blog/ios-http-urls.html
>>>>>>>> On Sunday, March 7, 2021 at 7:13:46 PM UTC+2 [email protected] 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Yes I'm using codename1.io.URL.
>>>>>>>>>
>>>>>>>>> On Sunday, March 7, 2021 at 11:46:23 AM UTC-5 Dennis Rogers wrote:
>>>>>>>>>
>>>>>>>>>> Sorry but I'm still having problems. I tried using unbuffered IO 
>>>>>>>>>> but with the same result (works on the simulator but not on the 
>>>>>>>>>> device). 
>>>>>>>>>> Also the code I sent you was followed by:
>>>>>>>>>>
>>>>>>>>>> // Get buffered Input stream
>>>>>>>>>>
>>>>>>>>>> is = link.getInputStream();
>>>>>>>>>> BufferedInputStream binp = new BufferedInputStream(is);
>>>>>>>>>> // Get reply
>>>>>>>>>> String ans = readLine(binp);
>>>>>>>>>>
>>>>>>>>>> which I think would qualify as asking for a response from the 
>>>>>>>>>> server. BTW this is all being done on a separate thread.
>>>>>>>>>>
>>>>>>>>>> I'm learning about the REST protocol but think this should work.
>>>>>>>>>>
>>>>>>>>>> -Dennis
>>>>>>>>>> On Saturday, March 6, 2021 at 9:32:02 PM UTC-5 Shai Almog wrote:
>>>>>>>>>>
>>>>>>>>>>> Are you using com.codenameone.io.URL ?
>>>>>>>>>>> I would recommend avoiding BufferedOutputStream in Codename One 
>>>>>>>>>>> as all streams are buffered by default in Codename One.
>>>>>>>>>>> You also need to fetch the result for the request to finish. It 
>>>>>>>>>>> won't happen until you try to get a response from the server.
>>>>>>>>>>>
>>>>>>>>>>> I would recommend using APIs like the "Rest" API which is 
>>>>>>>>>>> simpler to use and doesn't require threading.
>>>>>>>>>>>
>>>>>>>>>>> On Saturday, March 6, 2021 at 11:24:53 PM UTC+2 
>>>>>>>>>>> [email protected] wrote:
>>>>>>>>>>>
>>>>>>>>>>>> I have the following code that I use to send an email and 
>>>>>>>>>>>> password to my server. It works fine on the simulator but fails on 
>>>>>>>>>>>> an 
>>>>>>>>>>>> actual iphone (I receive a blank email and password):
>>>>>>>>>>>>
>>>>>>>>>>>> try {
>>>>>>>>>>>>     URL url = new URL(*"server address"*);
>>>>>>>>>>>>     link = url.openConnection();
>>>>>>>>>>>>     link.setDoOutput(true);
>>>>>>>>>>>>     link.setDoInput(true);
>>>>>>>>>>>> } catch(URISyntaxException e) {
>>>>>>>>>>>>     Log.p("URL error");
>>>>>>>>>>>>     Log.e(e);
>>>>>>>>>>>> }
>>>>>>>>>>>> // Get buffered output stream
>>>>>>>>>>>> os = link.getOutputStream();
>>>>>>>>>>>> BufferedOutputStream bout = new BufferedOutputStream(os);
>>>>>>>>>>>> // Send email and hashed Password
>>>>>>>>>>>> bout.write((nemail + "\n").getBytes());
>>>>>>>>>>>> pwHash = getHash(nemail + npasswd);
>>>>>>>>>>>> bout.write((pwHash + "\n").getBytes());
>>>>>>>>>>>> bout.flush();
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks, Dennis
>>>>>>>>>>>>
>>>>>>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/af35c4ad-e8fe-4fc2-b798-3f88af1cb72en%40googlegroups.com.

Reply via email to