How to stop delay when streaming data from a script as URL to an Applet?

I have a strange problem and do not know what is causing it. Hope someone here with some experience can help.
I have a Java Applet which makes a line graph of data. The data source is to be streaming, where the first chunk of data comes from what is already in a data file, and then new data is sent whenever it is ready. The problem in brief is that if I just collect and show the data from the data file and do not stream everything works fine. If I also have the streaming and wait for a long time, everything works fine, but when the applet is first loaded, the graph is not shown until after a long delay time.
Here is a snippet of the applet code:
         String dataendpoint = "http://phpfunction.php";
         URL url = new URL(dataendpoint);
         InputStream is = url.openStream();
         String line;
         InputStreamReader isr = new InputStreamReader(is);
         BufferedReader br = new BufferedReader(isr);
         while ((line = br.readLine()) != null) {
               // my code here to handle each line of data which prepares it for
               // showing on a line graph.
         } In the above, I show the dataendpoint variable hardcoded, but in reality this comes as an Applet parameter. It is a URL of a php script which is on the same server as the applet's code and there are no access problems here.
The PHP script does the following: It first opens a data file, parses it and prints it out to its standard output using echo or printf statements. The script then enters a loop where it periodically looks to see if new data has been made available. If so, that new data is also printed out to the standard output.
The PHP script looks like this (in pseudo code):
   // open data files, read lines, and send to standard output using echo
   // flush buffers using ob_flush() and flush() calls
   while (1) {
      sleep(30);
      // get new data, if any, then send to standard output
      // flush buffers again
   Again my problem: If I have the PHP script exit before the while loop everything works fine, my applet makes the graph immediately.
However, if I include the while loop, then initially the applet does not appear, not until some time afterwards, and then the applet works like it should, scrolling along every time new data arrives.
I have done a Wireshark sniff and I can see that the initial data is being sent out the the browser and applet immediately. So I do not think it is a buffering problem on the PHP side.
I have wrapped every Applet code line with debug print statements and from the Java console I see that the Java Applet is stopping at this line:
InputStream is = url.openStream();
Can someone explain what is happening here? Why the delay in returning from the openStream() function and how to avoid it?
By the way, the server is Linux and the Applet is being run on Windows Vista, and I have tried both Internet Explorer and Firefox, both give the same behavior.
Thanks in advance!
Steve, Denmark

I still cannot solve this problem, but I have some more observations:
1) yes it is a JApplet, and yes, the data streaming is performed in a separate thread.
2) Wireshark sniffing shows that data sent out by the PHP datasource on the server is sent immediately, and is not buffered (am using ob_start(), ob_flush() and flush() alls in the PHP script).
3) On Windows Vista, using Internet Explorer or Firefox, there is a constant 30 second delay before the Applet returns from this line: InputStream is = url.openStream();
4) After this 30 seconds, data appears in the Applet, but it can be seen also with java console debug prints that the data seems to be buffered. The newest data shown in the Applet is not the newest data sent to the client by the PHP datasource script.
5) On a SUSE Linux client, the Applet works as it should, there is no delay time in showing the data.
It appears as if there is on Windows a buffering of data which I do not wish to have and which does not occur on Linux. I need to find out how to get the URL openStream() call to return immediately allowing the initial data to be read and shown on the Applet. And I need to remove the buffering of data so that the data can be shown on the Applet when it arrives.
Can anyone help? Why does this work on Linux but not on Windows, and what can I do, at best within the Java code, to get the Applet to work on Windows as it does on Linux?
Thanks!
Steve, Denmark

Similar Messages

  • How to stop JSF requesting readonly data from applyRequestValues?

    Hello everybody,
    I need to optimise server performance without deep knowledge of jsf.. Not easy..
    Debugging I found the next dirty picture:
    Page1 shows some information which cannot be modified on this page, for example - top 10 winners. The Page1 has a commandLink which leads to Page2, no data processing needed when swithching to Page2.
    Click on that commandLink leads to full jsf lifecycle:
    1) execute()
    - restore view
    - applyRequestValues - here Page1 requests values, doing processDecodes on "<h:dataTable cellpadding="3" cellspacing="0" width="100%" border="0" var="product" value="#{HomeManager.top}">"
    - processValidations
    - updateModelValues
    - invokeApplication
    2) render()
    I see the same picture everywhere in the application.
    One solution is to use outputLink instead of commandLink.
    Then jsf does not go into the full lifecycle and would just render Page2.
    But I'm anyway interested to find the way to stop jsf from requesting readonly data, but still pass its lifecycle.
    I supposed that some jsf tags like panelGrid, dataTable or outputText have readonly attribute which will stop jsf from requesting data on applyRequestValues step, but found nothing about such attribute for these elements.
    I imagine I miss some key knowledge about jsf.. Can somebody help?
    Thanks in advance

    I still cannot solve this problem, but I have some more observations:
    1) yes it is a JApplet, and yes, the data streaming is performed in a separate thread.
    2) Wireshark sniffing shows that data sent out by the PHP datasource on the server is sent immediately, and is not buffered (am using ob_start(), ob_flush() and flush() alls in the PHP script).
    3) On Windows Vista, using Internet Explorer or Firefox, there is a constant 30 second delay before the Applet returns from this line: InputStream is = url.openStream();
    4) After this 30 seconds, data appears in the Applet, but it can be seen also with java console debug prints that the data seems to be buffered. The newest data shown in the Applet is not the newest data sent to the client by the PHP datasource script.
    5) On a SUSE Linux client, the Applet works as it should, there is no delay time in showing the data.
    It appears as if there is on Windows a buffering of data which I do not wish to have and which does not occur on Linux. I need to find out how to get the URL openStream() call to return immediately allowing the initial data to be read and shown on the Applet. And I need to remove the buffering of data so that the data can be shown on the Applet when it arrives.
    Can anyone help? Why does this work on Linux but not on Windows, and what can I do, at best within the Java code, to get the Applet to work on Windows as it does on Linux?
    Thanks!
    Steve, Denmark

  • Lag/delay when streaming Movies from external HD

    I'm streaming movies through iTunes on my iMac (with Airport Exteme) from an external HD.  Unfortunately, I'm experiencing a jerky/stuttering/flickering image even after it is finished buffering. Can someone please recommend a way to fix this?  I have too many movies to fit on my iMac's HD and need the external HD for storage, so I must find a way for this set up to work.
    Thanks!

    Thanks Alia,
    I'll try the Quicktime tip.  I've made sure all other apps are closed but still, all my HD seem to be lagging and stuttering a bit.  For all I've read in the forum, it seems many have the same issue, although many responses say they've found a solution.  I'm really hoping I can figure it out, I have way too many movies to fit in my iMac's harddrive.

  • How to stream data from TDS3000?

    Hi there,
    I would like to stream data from my scope into Labview for further analysis.
    Hardware: Tektronix TDS3014C
    Software: Labview SignalExpress 2.5.1 + Tektronix Extensions
    I don't exactly know when the interesting transient signal appears, therefore I would like to save ~5-10 s of streamed data.
    Right now I'm getting just fractions of 2 us and the scope switches into waiting for trigger.
    Is there a way to deactivate trigger, or a keyword I could search for?
    Thanks for your help,
    nook
    Solved!
    Go to Solution.

    muks,
    I think you got this post confused with another.
    nook,
    You can rarely continuously stream data from a GPIB scope. You can check the manual but often the scope cannot transmit at the same time it is acquiring so you have a sequential operation of wait, trigger, acquire, transfer, repeat.
    Can't you set the trigger for the transient?

  • How to get group when the data source from system instead of UME database

    Hig guys,
    How to get group when the data source comes from backend system instead of UME database?
    I tried to use
    IUMPrincipal RefGroup = WPUMFactory.getGroupFactory().getGroup(groupName);
    But I was not able to get the group. But in "UserAdministrator", I can find this groupName.
    Which kind of API can I use?
    Thanks in advance!
    Regards,
    Liying
    Message was edited by:
            Liying Wang

    Ok,
    try this:
    com.sapportals.portal.security.usermanagement.IGroupFactory ep5GroupFactory = userManagementService.getGroupFactory();
    IGroupFactory groupFactory = UMFactory.getGroupFactory();
    com.sap.security.api.IGroup group = groupFactory.getGroupByUniqueName(groupName);
    IUMPrincipal ep5Principal = ep5GroupFactory.getEP5Group(group);
    This should do the trick,
    Romano
    PS: and thanks for the stars!

  • I would like to know how i stop some albums ive bought from transfering to my iphone i delete them from itunes but when i sync my phone they transfer from my iphone this is a pain some one please help!!

    I would like to know how i stop some albums ive bought from transfering to my iphone i delete them from itunes but when i sync my phone they transfer from my iphone this is a pain some one please help!!

    Burb79 wrote:
    I thought of that one two tried it but still no joy. I have an ipad2 as well which I set up to not sync any music to it but for some reason the albums have got onto that as well. im thinkin its somthing to do with the dam cloud thing
    Go to Settings/ Store and under the category "Automatic Downloads" you can turn OFF the automatic download of purchases to your device (this needs to be done for each device). There's also a setting in iTunes just for automatic pushes to your iTunes library.
    To remove a purchase you've made directly to your device, you can either:
    a- Swipe across the song title from left to right and press Delete, or
    b- If you auto-sync your device, connect to iTunes and click on the Music tab where you define your sync settings (the Music tab is to the right of the overall Summary page of your device). At the bottom of the Music tab you'll see direct purchases that are on your device -- simply un-check those and click "Apply" or "Sync" to remove them.
    c- If you manually manage music on your device, connect to iTunes and click the small arrow to the left of your device name, and then click on the Music folder under your device. Then navigate to the item(s) you want to remove and then delete them.
    To prevent things from syncing from your library to your device, there are many ways to do that (un-checking things in your library is one way, but not the best IMO). Might want to read the manual or some online tutorials on iTunes if you want to learn more.

  • How to stop lion recovery disk assistant from downloading?

    Since I planned to upgrade the stock disk on my macbook pro I created a USB stick backup of the Lion OS using Lion recovery disk assistant. It built a bootable copy of my Lion OS. I replaced the drive, booted from the USB stick Lion, formatted the new drive with disk utility with one OSX partition, and bunch of Linux partitions for the planned dual/triple/etc. boot.  I then used the recovery disk menu to reinstall OSX on the new disk. It took off and started the download just like while booting with R key or from the recovery partition AGAIN!.  This is a 2 hour proposition and is totally ridiculous. I need to be able to reinstall without downloading Lion every time.   Any ideas on how to stop this new Apple invention from doing this download?

    If you read the Disk Recovery Assistant documentation all that it does is put a copy of the Recovery HD onto the flash drive. There is no OS on it to reinstall, hence the reason for the Internet download.
    If you wish to have a true bootable installer flash drive for your system, then here's what is involved. Start by going to this link: Downloading Hardware Specific Lion Installers. Follow the instructions very, very carefully because this can be a bit tricky.
    Once you have the installer application:
    Make Your Own Lion Installer
    1. After downloading Lion you must first save the Install Mac OS X Lion application. After Lion downloads DO NOT click on the Install button. Go to your Applications folder and make a copy of the Lion installer. Move the copy into your Downloads folder. Now you can click on the Install button. You must do this because the installer deletes itself automatically when it finishes installing Lion.
    2. Get a USB flash drive that is at least 8 GBs. Prep this flash drive as follows:
    Open Disk Utility in your Utilities folder.
    After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    3. Locate the saved Lion installer in your Downloads folder. CTRL- or RIGHT-click on the installer and select Show Package Contents from the contextual menu. Double-click on the Contents folder to open it. Double-click on the SharedSupport folder. In this folder you will see a disc image named InstallESD.dmg.
    4. Plug in your freshly prepared USB flash drive. You are going to clone the InstallESD.dmg disc image to the flash drive as follows:
    Open Disk Utility.
    Select the USB flash drive from the left side list.
    Click on the Restore tab in the DU main window.
    Check the box labeled Erase destination.
    Select the USB flash drive volume from the left side list and drag it to the Destination entry field.
    Drag the InstallESD.dmg disc image file into the Source entry field.
    Double-check you got it right, then click on the Restore button.
    When the clone is completed you have a fully bootable Lion installer that  you can use without having to re-download Lion.

  • How do i repair or recover data from a corrupt USB external hard drive that does not show up on my Mac desktop or disk utility

    How do i repair or recover data from a corrupt USB external hard drive that does not show up on my Mac desktop or disk utility?
    Last night i was using my external hard drive, for some reason the folder just closed and i couldn't find it on my desktop.
    After googling solutions, i found it in the disk utilities, i clicked on the 'repair' button many times, but it said the 'error...' message.
    So i ejected it to try again, now when i connect the USB external hard drive it doesn't show up on my desktop or disk utilities.
    I really just want to either repair or recover the data on it because it literally has everything (documents, work files, photos etc) on it,
    I downloaded an application to recover my files but it needs the USB to at least show up.recognise it which mine doesn't.
    I know i should've backed it up on another USB, this definitely teaches me for next time to back up all my files.
    Are the files lost forever or can i recover them by going to a shop or using a software?

    Thank you for responding.
    This might sound stupid since i'm not really knowledgeable with Macs,
    but since all my files were moved from my mac computer to the external hard drive,
    is it possible to recover those files through my Mac - like recovering deleted files? 

  • How do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full

    how do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full.. HELP!

    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.

  • How to eliminate subtitles when streaming Netflix through Apple TV?

    When streaming movies from Netflix through Apple TV, sub-titles appeared and we canot find a menu or symbol to click to eliminate the sub titles.  They carry over to our next item.  How can I eliminate the sub titles. (This is only a problem with Apple TV.  Able to eliminate them on computer or I Pad.

    Push and hold the menu button while the content is playing.  It will bring up a menu for captioning if the content has an option to chang it.

  • How do I transfer all my data from my original iPad 1 to my new iPad Air?

    How do I transfer all my data from my original iPad 1 to my new iPad Air?

    Do a full sync and backup of your one. I use iTunes for all my backing up. Then unplug the one and plug in the Air. Go through the setup process and when you have the choice to 'set up as new or restore from backup' chooose the the restore and your air will be a near clone of your One. You will need to reset up wifi and website passwords, but the data should be there.
    Once you are sure the Air has all you need on it, you can go into the settings and 'erase all content and settings' which puts your One back to the 'out of box' state to you can sell it if you want.

  • How do I transfer all my data from an iPad Air wifi 32 GB to a brand new iPad Air 2 64GB?

    I received right now a brand new iPad Air2 wifi 64 GB. How do I transfer ALL MY DATA from another iPad Air wifi 32 GB ?

    Back up your old one. I use and prefer iTunes, but back up all the data, etc.
    Then unplug it. Plug your new one in and go through the setup steps. When you see the option to set up as new or restore from the backup you just made, choose that and your new iPad will be a near clone of the old one.
    http://support.apple.com/en-us/HT2109
    has step to step instructions.
    If you are going to get rid of your old iPad, read this before you do so, just to make sure you're not inadvertantly selling someone a brick
    Selling an iPad
    http://support.apple.com/kb/HT5661

  • How do I delete all my data from computer mac?

    how do I delete all my data from computer mac?

    The Startup Manager may be necessary if the 'C' key fails:
    Use the Option key, when possible instead of 'C' key to boot discs

  • How to track the flow of data from R/2 to BI ?

    Hi Experts,
    Question: How to track the flow of data from R/3 to BI ?
    I want to load master data from R/3 to BI. In BI, i create an infopackage to load data from R/3. Under processing tab i set it as "PSA and then in the InfoObject (package by package)". Its a Full update.
    Now, i start the update to InfoObject. The load goes on well.
    Now, i want to track the flow of data from the master data table in R/3 to Datasource in R/3 then Extractors and then in the PSA in BI and then till the InfoObject. That is the complete flow of data from source table (in R/3) to Target table (in BI).
    Please help me know how this can be done. (For example lets take cost element master data)
    Regards,
    Suraj S Nair

    Hi,
    Data flow :
    BW :
    When u right click on the Master Data Info object -> Select Data flow.Then  it will  show u the details like DS name,IS (If 3.x)
    Once u know the DS then you need to find out the source tables for the R/3 DS.This information will get using ROOSOURCE or ROOSFIELD tables  or help.sap.com.
    My suggestion better to search in Help site for DS source tables.
    DS Tables :
    The following link will provide you the source tables for some of the LO DS.
    https://wiki.sdn.sap.com/wiki/display/BI/BWSDMMFIDATASOURCES
    Regards
    Ram.
    Edited by: Ramakanth Deepak Gandepalli on Dec 22, 2009 9:29 AM

  • Stream data from a subvi to the main vi - path refnum

    hello everyone
    sorry my english
    http://forums.ni.com/t5/LabVIEW/stream-data-from-a-subvi-to-the-main-vi/m-p/2205150/highlight/true#M...
    - refnum boolean worked
    - refnum graph worked
    - refnum numeric worked
    how to create a  path refnum? stream data from a subvi to the main vi
    where do I start?
    thank
    Solved!
    Go to Solution.

    Bom Dia Saille,
    Eu acredito que o que você tenha hoje seja isso aqui (Desenho bem simplificado):
    Hoje o que você tem é o Aplicativo do Medidor + USB Driver controlando o seu medidor. Basicamente, sua aplciação está dividida em três camadas:
    Aplicação - Onde estão as funcionalidades principais do programa (interface com o usuário, apresentação de dados, geração de arquivos, etc.)
    VISA - Uma arquitetura de Software para controle de instrumentos. Basicamente, ele se comunica com o Driver USB para poder enviar e receber pacotes de dados através do barramento USB.
    Device Driver - Intruções de SW de baixo nível para controlar um periférico através de um barramento.
    No desenho, eu aponto duas camadas onde você pode tentar atuar para automatizar suas medições:
    Aplicação - Você pode usar o VI Server para controlar o Aplicativo do Medidor (Se este aplicativo tiver sido desenvolvido em LabVIEW, o que eu suponho ser verdade). No entanto é necessário saber se o desenvolvedor do produto permitiu isso (Veja Using VI Server to Pass Data Between a VI and a LabVIEW Executable). Outra alternativa é conversar com o fabricante para ver se ele desenvolveu alguma API (Application Programming Interface) para que você consiga controlar o instrumento diretamente.
    VISA - O LabVIEW Fornece uma API chamada NI-VISA para poder enviar e receber informações através de diversos barramentos (Veja Serial Instrument Control Tutorial)
    É possível acessar o Driver diretamente também, mas eu não recomendo. O resultado não compensa o esfroço!
    Espero ter esclarecido suas dúvidas e espero que você tenha sucesso na sua aplicação!!
    Atenciosamente.
    Felipe Flores
    Engenharia de Aplicações
    National Instruments Brasil

Maybe you are looking for