linux os/400 connection fails at second try

ok. so, i strt a telnet connection to my as400 server wich works just fine. second time i try it, it fails ("Connection closed by foreign host"). more, no one else (as far as i test it) is able to connect using telnet. they stil can connect using client access or other "explorers", and also as400 still can connect to linux using telnet. what's happening here?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should check the system values QAUTOCRT and QAUTODEV. The first controls if devices (such as Telnet-display devices) may be created dynamically and the second controls how many devices (in total) may be dynamically created. Your first successful attempt to connect may have been to an already existing device and at your following attempts this device may have been occupied by somebody else. If you look in the AS/400, you may also check what device-types are available. Check with WRKCFGSTS *DEV QVRT* or WRKCFGSTS *DEV QPAD* which are defined and which are currently used. Also check if any are in pending or failed status.
One more comment: If available, use TN5250 - you've got much more control over function keys and the like.

Yes, the device ID of your telnet workstation may be vary off by AS400. so to make it easy, just vary on all device state with QPAD* using wrkcfgsts or wrkdevd.
Joakim, I'm looking for quite some time for a TN5250 for Linux. All there is now, is a Beta emulator.
Good connections between Linux and AS/400 are not quite that easy (if totally not) to make.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Well, that's true. Sorry to say, but I don't know of any TN5250-emulator for Linux - I only know that you you'll hate using VT100 or something similar with an AS/400. Keybord mapping and screen colours will only work if you use TN5250.

I'm sure you didn't find any cient access for Linux as well... :|
The only way i connect now, is using perl with odbc on the server, to talk native SQL.
Both machines do talk SQL....

Would like to see this though, since i like the stability of AS/400 and Linux.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Found it !!!

Here you find the only working tn5250 emulator for Linux.

I start it with:
xt5250 -s session -y IBM-3477-FC ipnumber

Where the IBM-3477-FC supports 132 columns.
guzu, your problem might be, that the as/400 has 132 colums, what is not supported under telnet wit 'vt100' screens.
so, download the latest program,
gzip -dc filename | tar -xvf-
go to new directory
../make check
../make install
in usr/local/bin there should be xt5250,
use the paramaters -s sessionname
-y screenname
ipnumber or hostname

Hope it helps,
Make sure that you are not connecting using a named session.  

For example,

  if you connect to the 400 using:
          tn5250 -s mysession  my.400.ip.address

then if you do a WRKACTJOB under QINTER you will see the device mysession logged in with your user id.  If you try to connect to the 400 again, then it will not let you, because it is trying to connect to the same device and it is already in use.

try to connect twice to the 400 just by using telnet from a command line.  To get your function keys use ESC + the number of the keyboard.  ( e.g.  for F11 use ESC + - for F16 use ESC + $ [Shift 4] ).  This will definitely dynamically assign device names for sure and you can then rule out if you are just running out of devices or if it is something simple like a named session.  

Hope this helps.
guzuAuthor Commented:
so, it has been proved that tn5250 is a great tool for conneting, also that my connection fails due to as400's telnet server failure... still, i don't know why, under some(?) conditions, the telnet server goes down... the last known example follows: after first try of tn5250, didn't know how to stop it (after logout) and tried Ctrl-C wich shows me a beautiful 'X SYSTEM' on the bottom of the screen, panic was there so i 'killall tn5250' and go home without looking back... the day after, there was no more TELNET server running on as400. i've looked at the logs and surprise! it was down after that Ctrl-C. can anybody tell me why?
Asta CuTechnical consultant & graphic designCommented:
This question is still open today and may just have been overlooked.  If you have been helped here, you may choose the comment which served you as the accepted answer to then grade and close so that others seeking help on this may find it in the PAQ database.

If more information is required, please post details here.

Thank you,
Asta CuTechnical consultant & graphic designCommented:
This question is still open today, perhaps it was overlooked or just lost in the volumes.  Please return to this question to update it with comments if more information is needed to get your solution.  If you've been helped by the participating expert(s), you may just convert their comment to the accepted answer and then grade and close.  If an answer has ever been proposed you may not have this option to accept the comment as answer, if that is the case, ask the specific expert you wish to award to post an answer.     This benefits others who then search our PAQ for just this solution, and rewards the experts who have provided information.  A win/win scenario.  Please DO NOT accept this comment as an answer,  it is merely a reminder.
If you wish to award multiple participants, you can do so by creating a zero point question in the Community Support topic area, include this link and tell them which experts you'd like to award what amounts.  If you'd like to delete this question, use the same process as above, but explain why you think it should be deleted.  Here is the Community Support link:
You can always click on your profile to see all your open questions, in the event you also have other open items to be resolved.   If your number of Questions Asked is not equal to the number of Answers Graded, choose to VIEW question history, and you'll quickly be able to navigate to your open items to close them as well.
I've had excellent help from experts-exchange through the years and find the real key to getting what I need is to remain active in all my questions, responding with results to suggestions until my solution is found, and recommend that highly.
Thank you very much for your responsiveness, it is very much appreciated.  
":0)  Asta

Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.